You get a stomach ulcer when the lining of your stomach or duodenum is damaged faster than it can repair itself. Two causes account for most cases: infection with Helicobacter pylori bacteria and regular use of NSAID pain relievers. Contrary to popular belief, spicy food and stress rarely cause ulcers on their own.

That distinction matters because it changes what actually helps. Treating an ulcer means removing the cause and supporting healing, not switching to bland food. This explainer walks through the biology of how ulcers form, who is at risk, what the numbers show, and which warning signs demand urgent care.

The biology of a breach in the wall

Your stomach lining is built for chemical assault. It secretes hydrochloric acid at a pH between 1.5 and 3.5, harsh enough to dissolve metal over time. A layered defense protects the tissue underneath.

Mucus cells release a thick bicarbonate-rich gel that keeps acid away from the surface. Beneath that, tight junctions between cells block acid from slipping through. Prostaglandins, hormone-like molecules made locally, keep blood flowing to the lining and drive mucus and bicarbonate production.

An ulcer forms when this defense fails at a specific point. H. pylori and NSAIDs both attack the defense rather than the acid itself. That is the first counterintuitive detail: most ulcers are not caused by too much acid. They are caused by a weakened wall meeting normal acid.

H. pylori is a spiral-shaped bacterium that burrows into the mucus layer and attaches to the cells beneath it. It produces urease, an enzyme that neutralizes acid around the bacterium, letting it survive in hostile territory. The immune response to the infection damages the lining further.

NSAIDs work differently. They block cyclooxygenase enzymes, which are required to make prostaglandins. Less prostaglandin means less mucus, less bicarbonate, and reduced blood flow to the stomach lining. The wall thins its defenses while acid production continues.

When the breach deepens past the mucosa, it becomes a true ulcer. If it erodes into a blood vessel, it bleeds. If it penetrates the full wall, it can perforate, a surgical emergency. This progression explains why early ulcers often cause only vague discomfort and later ones cause dramatic symptoms.

In plain terms: the stomach is a defended fortress, and ulcers are holes punched in the wall, not acid burning through healthy armor.

How common each cause is, by the numbers

H. pylori infection is the leading cause of peptic ulcers worldwide. The CDC estimates that H. pylori causes roughly 80 percent of stomach ulcers and about 90 percent of duodenal ulcers in the United States. The infection is less common in younger Americans than in older generations, and overall prevalence in the US has fallen to single digits in many age groups.

NSAID use is the second major cause. The FDA has long warned that NSAIDs carry a risk of serious gastrointestinal bleeding and ulcers. Risk rises with dose and duration. Low-dose aspirin, often taken for heart protection, is associated with a smaller but real increase in ulcer and bleeding risk.

A useful way to compare causes:

Cause Share of US ulcers Key mechanism Main risk amplifier
H. pylori infection About 80% of stomach ulcers Bacterial damage plus immune response Older age, poor sanitation exposure
NSAID use Most non-H. pylori cases Prostaglandin suppression Higher dose, longer use, age over 60
Low-dose aspirin Smaller but real share Partial prostaglandin suppression Prior ulcer history
Zollinger-Ellison syndrome Rare Massive acid overproduction Refractory ulcers
Idiopathic A minority Unknown or multifactorial None established

Cancer, Crohn's disease, and severe physiologic stress (such as in intensive care) cause a small fraction of ulcers. Zollinger-Ellison syndrome is rare enough that it should be suspected only when ulcers recur despite treatment.

Edge cases that change the picture

Age shifts the risk profile. People over 60 have higher rates of NSAID-related ulcers and bleeding, partly because NSAID use is more common for arthritis and partly because the stomach lining recovers more slowly.

Smoking slows ulcer healing and increases recurrence. It does not cause ulcers by itself, but it makes every other cause worse. Heavy alcohol use irritates the lining and can worsen bleeding risk, though it is not a primary cause.

Prior ulcer history matters more than most people realize. Someone who has had an NSAID-related ulcer and takes NSAIDs again faces a much higher risk of a second one, which is why clinicians often pair NSAIDs with a proton pump inhibitor in that group.

Rare genetic and physiologic conditions exist. Zollinger-Ellison syndrome involves a tumor that pumps out gastrin, driving extreme acid production. It accounts for a tiny share of ulcers but matters because standard treatment often fails.

H. pylori prevalence varies sharply by population. In parts of the world with less secure sanitation and water systems, infection rates are far higher than in the US. This is why travel and birth history can matter in a clinical evaluation.

One professional caveat: finding H. pylori does not prove it caused a particular ulcer. Many infected people never develop one, and ulcers sometimes have multiple contributors. Clinicians treat the infection when present, but they also look for other causes.

Misconceptions that delay real care

The stress-and-spicy-food theory persists despite decades of evidence against it. Stress can worsen symptoms and is associated with more reporting of digestive complaints, but it is not a primary cause of ulcers. Spicy food may irritate an existing ulcer, but it does not create one.

The "too much acid" model is incomplete. Acid is necessary for ulcers to form, but blocking acid alone often fails to cure an ulcer if the underlying cause, such as H. pylori or NSAID use, is not addressed. This is why modern treatment pairs acid suppression with cause removal.

The idea that ulcers are a lifelong condition is outdated. Most H. pylori-related ulcers heal after the infection is cleared, and most NSAID-related ulcers heal after the drug is stopped. Recurrence is common only when the cause returns.

A dangerous misconception is that ulcers are always mild. They can bleed heavily, perforate, or obstruct the stomach outlet. Those complications are emergencies and can be fatal if ignored.

Red-flag warnings that require urgent care:

Vomiting blood or material that looks like coffee grounds Black, tarry, or bloody stools Sudden severe abdominal pain, especially if the abdomen feels rigid Fainting, weakness, or signs of significant blood loss Unintentional weight loss or trouble swallowing

These signs mean the ulcer may be bleeding or perforated, and they warrant emergency evaluation rather than a wait-and-see approach.

What actually helps: practical steps and thresholds

Start by identifying the likely cause. If you take NSAIDs regularly, review that with a clinician. If you have persistent upper abdominal pain, testing for H. pylori is a reasonable step. The test is inexpensive relative to the cost of repeated visits and complications, though exact pricing varies by setting.

Concrete steps for people with symptoms:

Track NSAID use, including over-the-counter ibuprofen and naproxen. Note dose and frequency. Ask about H. pylori testing if symptoms persist beyond a couple of weeks. Avoid alcohol and smoking during healing, since both slow recovery. Do not start or stop prescription acid-suppressing drugs without guidance. Seek emergency care for any red-flag sign listed above.

For clinicians and patients weighing options, the table below compares common approaches:

Approach What it addresses Typical role Key limitation
H. pylori testing and eradication Bacterial cause First-line for infected patients Requires confirming eradication
Stopping or reducing NSAIDs Prostaglandin suppression Essential when NSAIDs are the cause Pain control may need alternatives
Proton pump inhibitors Acid suppression Supports healing alongside cause removal Does not remove H. pylori
H2 blockers Acid suppression Alternative acid control Less potent than PPIs
Misoprostol Prostaglandin replacement Sometimes used with NSAIDs Side effects limit tolerability

Testing matters because H. pylori eradication is highly effective when the infection is confirmed. Clinicians typically recheck after treatment to confirm the bacteria are gone, since failure rates exist.

A practical threshold: anyone with an ulcer and a history of NSAID use should discuss whether that drug can be stopped or paired with protective therapy. Anyone with an ulcer who tests positive for H. pylori should be treated for the infection.

Limits: what science still cannot settle

Not every ulcer has a clean explanation. A minority are idiopathic, meaning no H. pylori and no clear NSAID link. Research continues on whether other factors, including genetics and subtle immune differences, explain these cases.

H. pylori treatment resistance is a growing issue. Resistance to certain antibiotics varies by region, which is why regimens differ and why confirming eradication matters. This is a changing clinical area, and recommendations should come from current guidelines rather than fixed rules.

Symptom severity does not reliably track ulcer severity. Some people with significant ulcers have mild symptoms, and some with small ulcers have severe pain. This gap is why testing and, when appropriate, endoscopy matter more than symptom intensity alone.

The evidence is strongest for the two main causes and for cause-directed treatment. It is weaker for many lifestyle claims, and anyone promising that a diet change alone cures ulcers is overstating what is known.

The bottom line: how you get a stomach ulcer comes down to a breach in the lining's defenses, most often from H. pylori infection or NSAID use. Knowing the cause is what makes treatment work, and red-flag symptoms are what make timing matter.