How to Diagnose Ulcers: Endoscopy, H. Pylori, and More

Ulcers are typically diagnosed through one of two paths: a noninvasive test for the bacteria that cause most ulcers, or a direct look inside the stomach with a camera. Which path your doctor chooses depends largely on your age, your symptoms, and whether you have any warning signs that suggest something more serious.

The Two Main Diagnostic Paths

For most people under 60 with typical symptoms like burning stomach pain, bloating, or nausea, doctors start with a “test and treat” approach. This means testing for H. pylori, the bacterium responsible for the majority of peptic ulcers, without looking inside the stomach first. If the test comes back positive, treatment begins. If symptoms don’t improve, or if the initial picture is more concerning, an endoscopy follows.

The threshold drops to age 50 in populations with higher rates of stomach cancer, such as people who immigrated from East Asia, Eastern Europe, or parts of Central and South America. For anyone with alarm symptoms at any age, doctors skip straight to endoscopy. Those alarm symptoms include vomiting, gastrointestinal bleeding (blood in vomit or dark, tarry stools), unexplained weight loss, difficulty swallowing, iron deficiency anemia, or abdominal symptoms that persist even after an initial round of treatment.

People who regularly take aspirin or nonsteroidal anti-inflammatory drugs like ibuprofen, or who have a family history of stomach cancer, are also more likely to be referred for endoscopy early, even without alarm symptoms.

Testing for H. Pylori

Two noninvasive tests dominate H. pylori diagnosis: the urea breath test and the stool antigen test. Both can be done at a clinic or lab without any sedation or special preparation beyond stopping certain medications.

The urea breath test is the more accurate of the two. You swallow a small capsule or drink a solution containing a harmless tagged form of urea, then breathe into a collection bag 15 to 30 minutes later. If H. pylori is present in your stomach, the bacteria break down the urea and produce carbon dioxide that shows up in your breath sample. This test catches about 93% of infections and correctly rules out the bacteria about 92% of the time.

The stool antigen test looks for H. pylori proteins in a stool sample. It’s slightly less accurate, detecting about 87% of infections, and its ability to correctly identify people who don’t have the bacteria is lower at around 70%. It’s still widely used because it’s simple, inexpensive, and doesn’t require a clinic visit for the test itself.

Blood antibody tests also exist but are less useful. They can tell you if you were ever exposed to H. pylori, not whether you currently have an active infection. Most guidelines don’t recommend them as a first choice.

Medications That Interfere With Testing

If you’re taking a proton pump inhibitor (medications like omeprazole, lansoprazole, or esomeprazole), you need to stop for at least two weeks before either the breath test or stool test. These drugs suppress stomach acid enough to temporarily reduce H. pylori activity, which can produce a false negative. Antibiotics taken for any reason, even something unrelated like a sinus infection, require a four-week washout period before testing. Bismuth-containing products (such as Pepto-Bismol) also need to be stopped. Your doctor will give you specific timing, but knowing this in advance helps you avoid wasting a test.

What Happens During an Endoscopy

An upper endoscopy (sometimes called an EGD) is the gold standard for diagnosing ulcers. A thin, flexible tube with a camera on the end is guided through your mouth, down your esophagus, and into your stomach and the first section of your small intestine. The doctor can see ulcers directly, assess their size and location, and take small tissue samples for biopsy.

Preparation is straightforward. You’ll need to stop eating solid food at least eight hours beforehand and stop drinking liquids four hours before the procedure. Most people receive a sedative through an IV to stay relaxed and comfortable. An anesthetic spray numbs your throat before the tube goes in. The procedure itself usually takes 15 to 30 minutes, and you’ll spend another 30 to 60 minutes in recovery as the sedation wears off. You’ll need someone to drive you home.

Biopsies taken during endoscopy serve two purposes. First, they can test for H. pylori directly from stomach tissue, which is highly accurate. Second, for gastric ulcers specifically, biopsies help rule out stomach cancer. Duodenal ulcers (those in the first part of the small intestine) are almost never cancerous, so biopsies there are primarily for H. pylori detection.

Barium Swallow as an Alternative

A barium swallow, sometimes called an upper GI series, is a less invasive imaging option. You drink a chalky barium solution that coats the lining of your stomach and intestines, then X-rays are taken. Modern double-contrast techniques, which combine barium with gas to expand the stomach, perform nearly as well as endoscopy for detecting ulcers in clinical trials.

The limitation is that a barium swallow can’t take tissue samples. If a suspicious area shows up, you’ll still need an endoscopy for biopsy. For this reason, most doctors go directly to endoscopy when they suspect an ulcer that needs visual confirmation, especially in older patients where ruling out cancer is a priority.

When Doctors Look Beyond Standard Ulcers

Most peptic ulcers are caused by either H. pylori or regular use of anti-inflammatory painkillers. But when ulcers keep coming back despite treatment, appear in unusual locations, or are unusually severe, doctors may test for a rare condition called Zollinger-Ellison syndrome. This involves a tumor (called a gastrinoma) that produces excessive amounts of a hormone that drives acid production to extreme levels.

Diagnosis starts with a blood test measuring gastrin levels. Levels above 100 pg/mL raise suspicion. A level above 1,000 pg/mL combined with very acidic stomach contents is considered diagnostic. This condition accounts for a tiny fraction of ulcer cases, but identifying it changes treatment entirely, so it matters when the clinical picture doesn’t add up.

What Your Symptoms Can and Can’t Tell You

Classic ulcer pain is a gnawing or burning sensation in the upper abdomen, often between meals or in the middle of the night, that improves temporarily with food or antacids. Duodenal ulcers tend to cause pain two to five hours after eating, while gastric ulcers often hurt during or shortly after meals. Nausea, bloating, and feeling full quickly are common companions.

The problem is that these symptoms overlap heavily with acid reflux, functional dyspepsia (chronic indigestion without a visible cause), gallbladder issues, and even heart-related problems. Symptoms alone can’t confirm an ulcer. That’s exactly why the diagnostic process exists: to separate the possibilities with testing rather than guesswork. If your symptoms are mild, recently started, and you’re under 60 with no red flags, the H. pylori test-and-treat approach is a reasonable first step. If something about the picture is more urgent, endoscopy provides a definitive answer.