An ulcer is a sore that forms on the lining of your stomach or the first part of your small intestine. The only way to truly confirm you have one is with an endoscopy, where a doctor passes a thin tube with a camera down your throat. However, the process of diagnosing an ulcer usually starts long before that, with a careful look at your symptoms, your medical history, and some simple tests.
What Does an Ulcer Feel Like?
The most common symptom of a peptic ulcer is a burning or gnawing pain in the middle of the upper abdomen. This pain often occurs between meals or during the night when the stomach is empty. Some people find that eating food makes the pain better, while others find it makes it worse. The location and timing depend on whether the ulcer is in the stomach (a gastric ulcer) or in the duodenum (a duodenal ulcer).
Not everyone with an ulcer has pain. Some people have no symptoms at all until a complication develops. Others may experience bloating, heartburn, nausea, or feeling full quickly after eating a small amount of food. These symptoms are vague and overlap with many other digestive conditions, which is why symptoms alone cannot diagnose an ulcer.
When Should You See a Doctor?
You should see a doctor if you have persistent abdominal pain that does not go away with antacids or changes to your diet. You should seek urgent medical care if you vomit blood, pass black or tarry stools, or have severe abdominal pain that comes on suddenly. These can be signs of a bleeding ulcer or a perforation, which is a medical emergency.
Unexplained weight loss, difficulty swallowing, or anemia found on routine blood tests are also reasons to seek evaluation. These symptoms may point to an ulcer or to other conditions that need investigation.
How To Diagnose An Ulcer From Symptoms To Endoscopy
The diagnostic journey usually follows a stepwise path. Your doctor will first take a detailed history and perform a physical exam. They will ask about the exact location of your pain, what makes it better or worse, and whether you take nonsteroidal anti-inflammatory drugs (NSAIDs) like ibuprofen or naproxen. They will also ask about your alcohol use and whether you smoke.
After the history and exam, your doctor may order blood tests to check for anemia or signs of infection. They may also order a stool test to look for hidden blood. These tests are helpful but they do not diagnose an ulcer directly. They simply provide clues that point toward or away from one.
The two main ways to confirm an ulcer are an upper endoscopy and an upper GI series (barium swallow). Endoscopy is the gold standard because it allows the doctor to see the ulcer directly and take a biopsy if needed.
What Happens During an Endoscopy?
An upper endoscopy, also called an esophagogastroduodenoscopy (EGD), is a procedure that lets a gastroenterologist look at the lining of your esophagus, stomach, and duodenum. You will receive sedation to keep you comfortable. The doctor then passes a thin, flexible tube with a light and camera through your mouth into your digestive tract.
The procedure typically takes 15 to 30 minutes. You will be monitored as the sedation wears off, and most people go home the same day. During the procedure, the doctor can see if there is an ulcer, where it is located, and how large it is. They can also take small tissue samples (biopsies) to test for H. pylori bacteria or to rule out cancer.
Endoscopy is the most accurate way to diagnose an ulcer. No imaging test or blood test can match its precision. If your doctor suspects an ulcer based on your symptoms and risk factors, they may recommend endoscopy directly rather than starting with less definitive tests.
Testing for H. pylori
Most ulcers are caused by an infection with Helicobacter pylori (H. pylori), a type of bacteria that lives in the stomach lining. The other major cause is long-term use of NSAIDs. Testing for H. pylori is an essential part of the diagnosis because it changes the treatment approach.
There are several ways to test for H. pylori. A breath test measures the carbon dioxide in your breath after you drink a special solution. A stool test looks for bacterial proteins in your stool. Blood tests check for antibodies, but they are less reliable because they cannot tell the difference between a current and past infection. If you have an endoscopy, a biopsy taken during the procedure can also be tested for the bacteria.
If you test positive for H. pylori, your doctor will prescribe a course of antibiotics along with acid-reducing medication. This combination usually clears the infection and allows the ulcer to heal. Eradication of the bacteria is confirmed with a follow-up test several weeks after finishing the antibiotics.
Other Tests Your Doctor Might Use
An upper GI series uses X-rays to examine your upper digestive tract. You drink a chalky liquid containing barium, which coats the lining of your esophagus, stomach, and duodenum. The barium makes the organs visible on X-rays, and an ulcer shows up as a crater or niche in the lining.
This test is less invasive than endoscopy, but it is also less accurate. Small ulcers can be missed, and the test cannot take biopsies. It is rarely the first choice today when endoscopy is available. It may be used when a person cannot tolerate endoscopy or when endoscopy is not available.
CT scans are not routinely used to diagnose ulcers. They may be ordered in the emergency setting if a perforation is suspected, but they are not the standard tool for finding an ulcer.
What Else Could It Be?
Ulcer symptoms overlap with several other conditions. Gastroesophageal reflux disease (GERD) causes heartburn and chest pain. Gallstones can cause upper abdominal pain, especially after fatty meals. Gastritis is inflammation of the stomach lining without an actual sore. Functional dyspepsia is a term for chronic upper abdominal discomfort with no clear cause found on testing.
Your doctor will consider these possibilities based on your specific symptoms and risk factors. This is another reason why endoscopy is so valuable — it provides a clear answer rather than relying on guesswork. If the endoscopy is normal, your doctor can shift focus to these other conditions.
What Happens After Diagnosis?
Treatment depends on the cause of the ulcer. If H. pylori is found, you will take antibiotics plus a proton pump inhibitor (PPI) to reduce stomach acid. If NSAIDs are the cause, you will need to stop taking them or switch to a different medication. PPIs like omeprazole or esomeprazole are the mainstay of ulcer treatment because they reduce acid production and allow the ulcer to heal.
Most ulcers heal within 4 to 8 weeks of treatment. Your doctor may recommend a repeat endoscopy to confirm healing if the ulcer was large or if it was in the stomach, because stomach ulcers carry a small risk of being cancerous. Repeat testing for H. pylori is also important to confirm the infection is gone.
If you have a bleeding ulcer, treatment may involve cauterizing the bleeding vessel during endoscopy or injecting medication to stop the bleeding. This is done immediately during the procedure and is highly effective.
Can You Prevent Ulcers?
If you take NSAIDs regularly, talk to your doctor about whether you need them. Taking the lowest effective dose for the shortest time reduces your risk. Some people who need long-term NSAID therapy may also take a PPI to protect the stomach lining.
Avoiding excessive alcohol and not smoking also lower your risk. Both can irritate the stomach lining and delay healing of an existing ulcer. There is no specific diet that prevents ulcers, but eating regular meals and avoiding foods that trigger your symptoms can help you feel better while you are being treated.
Frequently Asked Questions
Can a doctor diagnose an ulcer without an endoscopy?
No, an endoscopy is the only way to definitively confirm an ulcer. Your doctor can suspect one based on symptoms and risk factors, but imaging and lab tests cannot match the accuracy of direct visualization.
Is an endoscopy painful?
No, you receive sedation before the procedure, so you will be relaxed and comfortable. Most people have no memory of the procedure and experience only mild throat discomfort afterward.
How long does it take to recover from an ulcer?
Most ulcers heal within 4 to 8 weeks of proper treatment. If H. pylori is present, completing the full antibiotic course is essential for healing and preventing recurrence.
What does black stool mean if I have an ulcer?
Black, tarry stools can indicate bleeding from an ulcer in the stomach or duodenum. You should seek urgent medical attention if you notice this symptom.

