Vagus Nerve.
The direct line where most of this happens is the Vagus Nerve. Think of this as the superhighway that directly connects your gut to your brain.
The Vagus Nerve carries important messages about digestion, hunger, stress and emotions. If your gut is irritated, your brain gets that signal and might react with mental fog, mood swings or anxiety.