Some studies found a small risk of anxiety with pantoprazole use. However, the link is not well established. Anxiety during pantoprazole treatment can be a sign of brain-gut axis dysfunction. Also, anxiety may result from other side effects of long-term use of pantoprazole, such as magnesium and vitamin B12 deficiency.
Your brain and your digestive system are tightly and profoundly interlinked. For example, your digestive system has many nerve cells that are considered an entire system called the (enteric nervous system). Most common functional gut diseases such as IBS and functional dyspepsia are linked to anxiety and other psychological dysfunctions.
Stress is known to influence your digestive system. Many functional Gastrointestinal diseases such as Irritable bowel syndrome and functional dyspepsia are linked to psychological factors such as stress.
Another theory is that stress, anxiety, and depression may affect your immune system. a weakened immune system can trigger inflammation and infections such as appendicitis