Why Does My Stomach Keep Hurting On and Off?

Recurring stomach pain often comes down to a handful of causes like IBS, food intolerances, or stress. Here’s how to figure out what’s behind yours.

Intermittent stomach pain is one of the most common reasons people visit a doctor, and in the majority of cases it stems not from structural damage or disease but from how the gut processes and transmits signals. The medical term for this broad category is “functional” pain, meaning the gut looks normal on scans and scopes but still hurts. That said, the on-and-off pattern does not automatically rule out something more concrete like an infection, inflammation, or a food intolerance. The real challenge is figuring out which category your pain falls into, because the sensation itself can feel identical.

Functional Pain vs. Something Structural

Doctors sorting out recurring abdominal pain start with a basic question: is this functional or organic? “Organic” means there is a visible, measurable cause, like an ulcer, a gallstone, or inflamed intestinal tissue. “Functional” means the pain is real but the usual tests come back normal. Distinguishing between the two matters because the treatments diverge sharply, and over-testing with invasive procedures carries its own costs and risks.

Abdominal pain and changes in bowel habits are common enough in the general population that deciding who genuinely needs endoscopy or imaging is one of the harder calls in gastroenterology. The goal is to avoid both extremes: running every patient through expensive, uncomfortable procedures and missing a disease that could cause real harm if ignored. In children, where recurrent abdominal pain is especially prevalent, guidelines recommend a thorough history and physical exam plus a small number of lab tests before reaching for anything invasive.

In practice, most people with on-and-off stomach pain land in the functional category. Irritable bowel syndrome alone affects a sizable share of the adult population worldwide, and functional dyspepsia (recurring upper-belly discomfort without an obvious cause) is nearly as common. These are not diagnoses of exclusion made by throwing up your hands. They have their own defined criteria, and a skilled clinician can often identify them from the pattern of symptoms without needing to scope every patient.

Visceral Hypersensitivity and the Overreactive Gut

If nothing is structurally wrong, why does it still hurt? The leading explanation for functional abdominal pain centers on something called visceral hypersensitivity. Under normal circumstances, your gut stretches, contracts, and moves food along without you feeling much of anything. The signals travel from the digestive tract through the spinal cord to the brain, but the brain typically files them away as background noise.

In people with visceral hypersensitivity, the volume knob on those signals is turned up. Ordinary stretching or gas production that a healthy gut would ignore gets registered as pain or discomfort. This is considered one of the key mechanisms behind IBS and similar conditions. The problem can sit at the gut wall itself (peripheral sensitization), in the spinal cord (central amplification), or in the brain’s processing centers. Often it is a mix of all three.

This explains the on-and-off nature of the pain. The sensitivity fluctuates. On a calm day with regular meals and decent sleep, the signal volume stays manageable. Add stress, a large meal, hormonal shifts, or a night of poor sleep, and the threshold drops. Suddenly the same amount of intestinal gas or movement that you barely noticed yesterday feels like cramping or a dull ache. The gut has not changed structurally between those two days; the signaling has.

How Stress Feeds Into the Cycle

The gut and the brain talk constantly through what researchers call the brain-gut axis, a two-way communication highway involving nerves, hormones, and immune signals. Stress hijacks this system in multiple ways. It alters how fast food moves through the digestive tract, ramps up the gut’s sensitivity to normal sensations, changes digestive secretions, and even increases the permeability of the intestinal lining.

This is not the same as saying the pain is “all in your head.” It is a physiological cascade. Stress hormones act directly on the gut, making it move differently and feel things more intensely. In people who already have some degree of visceral hypersensitivity, psychological stress can push them past the threshold where normal gut activity starts registering as pain. This is one reason why the pattern tends to be intermittent: pain flares during stressful periods and eases when life calms down.

There is also a feedback loop. Chronic abdominal pain itself becomes a source of anxiety, which increases gut sensitivity, which generates more pain. Studies of IBS patients show that psychosocial risk factors and local gut inflammation interact with each other, meaning addressing only one side of the equation often fails.

Food and the FODMAP Connection

If your stomach pain tends to show up after meals but not always the same meal, certain poorly absorbed carbohydrates may be the culprit. These are collectively known as FODMAPs (fermentable oligosaccharides, disaccharides, monosaccharides, and polyols), and they include things like fructose in excess of glucose, lactose, sugar alcohols in “sugar-free” products, and certain fibers found in wheat, onions, garlic, and legumes.

These carbohydrates are not inherently harmful. In a gut with normal sensitivity, they pass through, get fermented by bacteria, and cause minor gas production that you barely notice. But they draw extra water into the small intestine through osmotic pull and generate gas in the colon, and in someone with visceral hypersensitivity, that combination translates to bloating, cramping, and pain. MRI studies have confirmed this directly: after eating high-FODMAP foods, people show increased water in the small bowel and more gas in the colon, and those with a sensitive gut report more symptoms.

The intermittent nature fits here because your FODMAP intake varies day to day. A salad with no onions on Monday, a garlic-heavy pasta on Tuesday, an apple and a handful of cashews on Wednesday. The pain follows the load, but the delay between eating and symptoms (often several hours) makes it hard to pinpoint which food was the trigger without a structured elimination approach.

Infections That Start the Problem or Keep It Going

A bout of food poisoning or gastroenteritis can be the origin story for ongoing intermittent pain. This is called post-infectious IBS, and it happens in a meaningful percentage of people after a severe GI infection. The infection clears, but the gut remains sensitized, sometimes for months or years. The interaction between the initial inflammation and the person’s psychological response to the illness appears to predict who develops long-term symptoms and who bounces back quickly.

Chronic low-grade infections can also produce on-and-off pain directly. Helicobacter pylori, the bacterium linked to stomach ulcers, was found in about 40% of children undergoing endoscopy for recurrent abdominal pain in one study. All infected patients had chronic gastritis, and after standard antibiotic treatment, about 80% of those who came back for follow-up saw their symptoms resolve. H. pylori is worth checking for because it is common, treatable, and often silently present for years.

Small intestinal bacterial overgrowth (SIBO) is another possibility. When bacteria that normally live in the large intestine colonize the small intestine, they ferment food earlier than they should, causing bloating, pain, and altered bowel habits. The presentation ranges from barely noticeable to chronic diarrhea with weight loss. SIBO can wax and wane depending on diet, motility patterns, and antibiotic use, which contributes to the on-and-off rhythm.

Inflammatory and Immune-Related Causes

Intermittent pain does not rule out inflammatory bowel disease. Over 70% of people with IBD (Crohn’s disease or ulcerative colitis) report abdominal pain at some point, and a substantial fraction continue to experience pain even during remission, when their disease markers look quiet. Up to about a third of people with ulcerative colitis in remission and more than 60% of those with Crohn’s in remission report ongoing symptoms including chronic pain. The flare-and-remission pattern of IBD naturally produces on-and-off pain, and remission does not always mean pain-free.

Celiac disease is another inflammatory condition that gets missed. When someone with celiac continues to eat gluten, the damage to the small intestine fluctuates with exposure. Even after diagnosis and adoption of a gluten-free diet, some people continue to have symptoms. In one study of celiac patients who had been on a gluten-free diet, a substantial group still reported abdominal pain and constipation, and villous atrophy remained far more common in those with persistent symptoms. Undiagnosed celiac often masquerades as IBS for years because the symptoms overlap so heavily.

A less familiar possibility involves mast cells in the gut lining. Research has identified people with functional GI symptoms like pain, bloating, and changes in bowel habits who have abnormally high numbers of mast cells in biopsies from the stomach, small bowel, and colon. When these mast cells are identified and treated with targeted therapies, some patients improve. This is still a developing area of research, but it suggests that some people labeled with functional pain actually have an identifiable immune process driving their symptoms.

Medications That Quietly Irritate the Gut

If you regularly take over-the-counter painkillers like ibuprofen or naproxen, they may be contributing to the very pain you are trying to treat. Nonsteroidal anti-inflammatory drugs (NSAIDs) work by blocking enzymes that produce prostaglandins, which mediate inflammation. The problem is that some of those same prostaglandins also protect the stomach lining. Without them, the mucosa becomes more vulnerable to acid damage.

NSAIDs can also enhance gut motility, which accelerates the cascade of mucosal damage: increased permeability, immune cell infiltration, and oxidative stress in the stomach wall. The result can range from mild, vague stomach discomfort to full-blown ulcers. Because people tend to use NSAIDs intermittently (a few days for a headache, a week for back pain, then nothing for a while), the stomach pain mirrors that intermittent use. Antibiotics, iron supplements, and certain antidepressants are other common medications that can cause recurring GI discomfort through different mechanisms.

Causes That Get Missed

Several diagnoses are routinely overlooked in people with recurring abdominal pain, either because they are uncommon or because clinicians do not think to look for them.

Abdominal migraine is one of the more surprising. Commonly diagnosed in children, it also occurs in adults. Episodes involve moderate-to-severe central abdominal pain lasting hours, often with nausea or vomiting, followed by completely symptom-free intervals. There is usually a personal or family history of migraine headaches. The condition appears to involve a disturbance in the brain-gut axis similar to what drives migraine headaches, and it shares neuroinflammatory and neuroimmune pathways with other migraine variants. If your pain comes in distinct episodes with clear periods of feeling completely fine, and especially if migraines run in your family, this is worth raising with your doctor.

Anterior cutaneous nerve entrapment syndrome (ACNES) is another blind spot. In this condition, a small nerve in the abdominal wall gets trapped where it passes through muscle tissue, causing localized pain that mimics an internal problem. The pain can be intermittent because it worsens with certain movements or postures and eases at rest. Diagnosis involves a physical exam maneuver called Carnett’s sign, where the pain increases when the patient tenses the abdominal muscles. A local anesthetic injection at the tender point can both confirm the diagnosis and relieve symptoms. Many patients with ACNES cycle through GI workups for years before someone checks the abdominal wall itself.

For people who menstruate, bowel endometriosis is another frequently delayed diagnosis. Endometrial tissue growing on or near the intestine can cause pain that waxes and wanes with the menstrual cycle. The majority of women with bowel endometriosis develop gastrointestinal complaints, but the symptoms often get attributed to IBS because the overlap is so large. A cyclical pattern of pain that consistently worsens around menstruation is a clue.

How Lifestyle and Diet Quality Factor In

Beyond specific food triggers like FODMAPs, the overall quality of your diet and the regularity of your daily routines influence gut behavior in ways that can produce intermittent symptoms. Ultra-processed foods, which make up a large portion of the modern Western diet, contain additives and non-nutritive ingredients that can disrupt the intestinal barrier. Preclinical and clinical evidence suggests these substances negatively affect the gut microbiota, the protective mucus layer, the intestinal lining, and the immune cells beneath it. A damaged barrier exposes the immune system to more bacteria than it should encounter, potentially driving inflammation.

Disrupted sleep and irregular schedules also play a role. The gut runs on circadian rhythms just like the brain does, with motility, secretion, barrier function, and immune activity all cycling on roughly 24-hour clocks. Shift work and irregular sleep patterns disrupt these peripheral clocks, altering gut motility and barrier integrity. If your pain tends to flare during stretches of poor sleep or chaotic eating schedules, the disruption to your gut’s internal clock may be part of the explanation.

Red Flags Worth Knowing

Most intermittent abdominal pain is manageable and not dangerous, but certain features should prompt a faster or more thorough evaluation. A study of children with recurrent abdominal pain identified several warning signs that predicted an organic cause: fever, pain located away from the belly button area, pain that wakes you from sleep at night, unexplained weight loss, growth problems, elevated inflammatory markers on blood work, and tenderness on physical exam. These red flags apply to adults as well, with the addition of blood in the stool, new onset of symptoms after age 50, a family history of colon cancer or IBD, and unintentional weight loss of more than a few pounds.

The absence of red flags is itself useful information. If your pain comes and goes, sits in the central or lower abdomen, does not wake you up at night, does not come with weight loss or blood, and worsens during stressful periods or after certain meals, the odds favor a functional cause. That does not mean you should ignore it, but it does mean you can approach the workup and management more gradually rather than rushing to invasive tests. Working with a gastroenterologist to systematically address triggers, including diet, stress, sleep, and medication use, often produces more relief than chasing a single structural explanation that may not exist.