Most peptic ulcers are preventable because they stem from two well-understood causes: a bacterial infection called H. pylori and regular use of common pain relievers like ibuprofen and aspirin. About half of bleeding ulcers are linked to these pain medications, and a large portion of the rest trace back to the bacterial infection. Knowing which risk factor applies to you is the first step toward keeping your stomach lining intact.
The Two Main Causes You Can Control
H. pylori is a stomach bacterium that weakens the protective mucus lining, allowing acid to damage the tissue underneath. It spreads through person-to-person contact, contaminated water, and poor sanitation. Infection rates have dropped dramatically in places with modern plumbing and hygiene infrastructure, but the bacterium still clusters in households where one person is already infected, especially in crowded living conditions.
NSAIDs (nonsteroidal anti-inflammatory drugs) are the other major culprit. Ibuprofen, aspirin, and naproxen work by blocking an enzyme involved in inflammation, but that same enzyme also produces the protective coating inside your stomach. Without it, acid eats into the stomach wall. The risk is highest in the first one to three months of regular use, at higher doses, and in people over 65.
Safer Approaches to Pain Relief
If you take ibuprofen or aspirin occasionally for a headache, your risk is low. The danger rises with daily or near-daily use, especially if you’re older, take blood thinners, or use corticosteroids at the same time. People on blood thinners who also take NSAIDs face roughly 13 times the normal risk of hospitalization for stomach bleeding.
Acetaminophen (Tylenol) is the simplest swap. It relieves pain without touching the stomach lining because it works through a different mechanism. It won’t help much with inflammation, but for general aches and mild arthritis pain, it’s a reasonable first choice.
When you genuinely need an anti-inflammatory, talk to your doctor about taking the lowest effective dose for the shortest time. If long-term NSAID use is unavoidable, a stomach-protecting medication called a proton pump inhibitor (PPI) can cut your risk of developing a gastric ulcer by about 60%. For people at the highest risk, combining a COX-2 selective anti-inflammatory (a prescription NSAID designed to spare the stomach) with a PPI offers the strongest protection. Standard-dose acid reducers like famotidine can protect the upper intestine but are not reliable at preventing stomach ulcers on their own, so they’re not the best standalone option.
Reducing H. Pylori Risk
H. pylori is an infection, and like other gut infections such as hepatitis A and cholera, its spread is tied to hygiene. You can reduce your chances of picking it up with straightforward habits: wash your hands thoroughly before eating and after using the bathroom, drink water from clean sources, and avoid sharing utensils or cups with someone who has an active stomach infection.
If you already have recurring stomach pain or a family member has been treated for H. pylori, it’s worth getting tested. A simple breath test or stool test can detect the bacterium. Treatment is a short course of antibiotics combined with an acid-reducing medication, and clearing the infection dramatically lowers your chance of developing an ulcer. Smoking increases susceptibility to H. pylori, giving you one more reason to quit if you’re at risk.
How Smoking and Alcohol Raise Your Risk
Smoking weakens the valve between your stomach and esophagus, allowing acid to splash where it shouldn’t. It also reduces blood flow to the stomach lining, which slows healing of any damage that does occur. Smokers are more likely to become infected with H. pylori in the first place, and once infected, their ulcers are slower to heal and more likely to come back.
Heavy alcohol use irritates and erodes the stomach lining directly. Moderate drinking on its own is less clearly linked to ulcers, but when combined with smoking or NSAID use, the damage compounds. If you’re already taking a daily aspirin for heart health, even moderate alcohol adds meaningful stomach risk.
What to Eat (and Avoid) for Stomach Protection
A fiber-rich diet acts as a buffer against ulcers. Fiber reduces the concentration of bile acids in the stomach and helps regulate how quickly food moves through the digestive tract, which means less bloating, less acid contact with vulnerable tissue, and less discomfort. The World Health Organization recommends 20 to 30 grams of fiber daily. Research on ulcer patients consistently finds that those with ulcers tend to eat diets low in fiber and antioxidants.
Good choices include apples, pears, bananas, oatmeal, dark leafy greens, carrots, zucchini, lean meats, and nuts like walnuts and flaxseed. Foods to be cautious with include acidic fruits (oranges, pineapple, lemon), gas-producing vegetables (broccoli, cabbage, raw onion), and spicy peppers. Coffee, black tea, and carbonated drinks can also aggravate the stomach lining, so cutting back helps if you’re prone to irritation.
Probiotics, particularly strains of Lactobacillus, show promise as a complement to ulcer prevention. One clinical trial found that Lactobacillus reuteri reduced H. pylori levels significantly after four to six weeks and decreased abdominal pain and bloating by 15% compared to standard treatment alone. Probiotics won’t replace antibiotics for an active infection, but they support gut health and may reduce the side effects of treatment if you do need it. Yogurt, kefir, and fermented foods are easy dietary sources.
Stress as a Real Risk Factor
For decades after the discovery of H. pylori, stress was dismissed as an ulcer cause. The science has caught up with what many patients experience firsthand. A large register-based study found that people reporting the highest levels of psychological stress had 2.2 times the risk of developing a peptic ulcer compared to those with the lowest stress, even after adjusting for NSAID use, smoking, and socioeconomic status.
Stress doesn’t burn a hole in your stomach by itself. It alters blood flow to the stomach lining and increases acid secretion, which creates conditions where existing damage is slower to heal and new damage is more likely to take hold. It also tends to push people toward the behaviors that directly cause ulcers: more smoking, more drinking, more over-the-counter painkillers. Managing stress through exercise, sleep, or whatever works for you isn’t just general wellness advice. It has a measurable effect on your stomach.
Who Needs Preventive Medication
Not everyone who takes an occasional ibuprofen needs a prescription to protect their stomach. But certain combinations of risk factors change the math considerably. You’re at higher risk if you:
- Are over 65. Age alone raises the odds of a bleeding ulcer nearly fivefold among regular NSAID users.
- Take higher NSAID doses. Higher doses carry roughly eight times the risk compared to non-users.
- Started NSAIDs recently. Counterintuitively, the first three months are the most dangerous period.
- Also take blood thinners or corticosteroids. These combinations multiply the risk dramatically.
- Have a history of ulcers or stomach bleeding. A previous ulcer is one of the strongest predictors of a future one.
If two or more of these apply to you, a daily PPI while you’re on NSAIDs is a straightforward protective step. Among patients with prior bleeding ulcers, even the best prevention strategies carry some residual risk, so minimizing NSAID use altogether remains the safest path when alternatives exist.

