When Rep. Debbie Dingell (D-Mich.) woke up at 3 a.m. on Friday with intense abdominal pain, she initially thought it was just a bad bout of gas. She tried moving around, drinking water, running a hot bath and taking Gas-X and Tylenol. But nothing worked.

“I was just on fire,” Dingell, 67, said in a telephone interview. “I could barely walk, it hurt so much.”

Within hours of arriving at George Washington University Hospital later that day, Dingell was rushed into emergency surgery. The reason? A perforated ulcer, which she and her doctors believe was probably caused by her prolonged use of an over-the-counter pain reliever found in many people’s medicine cabinets: Motrin, or ibuprofen.

“We think if we’re taking over-the-counter medicines and we’re not feeling anything, we’re okay,” said Dingell, who had been using high doses of Motrin to help with lingering pain from surgery earlier this year. “I didn’t know I had an ulcer,” she added. “I had no stomach pain before this.”

Taking pain relievers such as Advil, Motrin, Aleve or aspirin, also known as nonsteroidal anti-inflammatory drugs (NSAIDs), is one of the most common causes of ulcers, experts say. But “there’s a real education gap” among members of the public about the potentially serious side effects of these medications, said Kyle Staller, director of the Gastrointestinal Motility Laboratory at Massachusetts General Hospital.

“Just because something’s available over the counter doesn’t mean it’s safe to be used by everyone for any amount of time,” Staller said. Though NSAIDs are “wonderful medications for the relief of pain,” he said, it’s important to remember how powerful they are.

Here’s what experts say the public should know about NSAIDs and ulcers — and why Dingell’s experience should serve as a cautionary tale.

How do ulcers develop?

NSAID usage isn’t the only reason ulcers develop in the stomach or upper area of the small intestine. Another common culprit is a bacterial infection caused by Helicobacter pylori, or H. pylori. And although NSAIDs and H. pylori infection are independent risk factors, Staller said, they can work together to increase a person’s chances of developing ulcers.

Dingell’s case appears to be more directly tied to taking ibuprofen, however. The “saga,” as she calls it, started months ago, when a bothersome dental implant led to a bone infection in her jaw. After she had jaw surgery in January, the lawmaker, who has been outspoken about the dangers of opioids and narcotics, instead opted to take Motrin for pain relief.

Soon, Dingell said, she was regularly downing 800 mg morning and night, which continued long after the initial surgery. By around March, Dingell said, her doctors started to raise concerns about how much ibuprofen she was taking.

“The doctors warned me,” she said. “They told me that taking it for this long, they wanted to watch me closely, and I thought I was invincible.”

Ibuprofen and other pain relievers such as naproxen, or Aleve, reduce your body’s ability to make a layer of mucus that protects the lining of your stomach from gastric acid, said Christian Stevoff, clinical practice director in the division of gastroenterology at Northwestern University’s Feinberg School of Medicine.

There is a small chance that ingesting the medicine can have a “direct, toxic, topical effect,” he said, but “the larger effect appears to be more systemic, like through the bloodstream.” For example, some people who receive NSAIDs through an IV will develop stomach ulcers.

What about diet and stress?

The idea that ulcers can be caused by taking over-the-counter pain relievers may come as a surprise to people who have long believed that diet and stress are major factors.

Dingell, a self-described “junk food queen” and “Diet Coke addict,” who typically drinks 10 to 12 bottles a day, said she anticipated being told by her doctors that she would need to make changes to her diet. But, experts said, the belief that certain foods and carbonated or acidic beverages can cause or worsen ulcers is a common misconception.

“Either of those can cause abdominal pain for different reasons,” Stevoff said. “A lot of times, people equate their abdominal pain with having an ulcer.”

Your gastrointestinal (GI) tract “only has a limited amount of ways to express its displeasure,” Staller said, such as nausea, vomiting, a “sour stomach” or indigestion, pain and bowel symptoms. It can be challenging for laypeople and doctors to determine what’s causing symptoms, and it’s common to confuse another gastrointestinal malady, such as indigestion, with ulcers, he said. The vast majority of patients with indigestion that Staller performs endoscopies on “don’t have an ulcer when we look,” he added.

Stress also is not widely believed by experts to have a significant effect on ulcer formation, and research hasn’t presented conclusive findings. “It’s very hard to measure stress and identify that as the cause for ulcers,” said Marie Borum, director of the gastroenterology division at George Washington University.

Other behaviors, though, such as smoking and heavy alcohol use, are known risk factors, said Tsion Abdi, a gastroenterologist and assistant professor of medicine at Johns Hopkins University. Elderly people or those who regularly take other medications, including low-dose aspirin, may also have a greater chance of developing ulcers and suffering from complications, Stevoff said.

Knowing if you have an ulcer

Burning stomach pain, burping, bloating and heartburn are among the common signs of an ulcer, Abdi said. But Borum noted that it’s not unusual for people with ulcers to be asymptomatic until they develop a complication, such as bleeding or perforating, as in Dingell’s case. About 2 to 10 percent of ulcer patients will experience a perforated ulcer, which often manifests as “acute, severe and diffuse abdominal pain,” Borum said.

Because of the overlap between symptoms of various gastrointestinal problems, Borum urged people to pay attention to their bodies. If your symptoms are recurring, persistent and increasing in severity, “you should definitely seek medical attention,” she said.

How to prevent, treat ulcers

To lower your risk of ulcers, follow the recommended-use instructions on products containing NSAIDs, Abdi said. These typically note that the medication shouldn’t be taken for longer than 10 to 14 days. “The longer you take it and the higher dose that you take it outside of the labeled use, you’re at greater risk for developing complications,” she said.

Switching to a lower-risk pain reliever, such as Tylenol, or acetaminophen, may also be helpful, experts said. But although acetaminophen treats pain, it isn’t an anti-inflammatory, and taking too much can cause liver damage.

Experts recommended that people who use NSAIDs to help manage chronic pain talk with their health-care provider, rather than self-medicate. Keep in mind that there isn’t a specific dosage or use period that is considered universally safe, Stevoff said.

“Everybody’s different,” he said. “For some people, they can take massive doses of these things and never have a problem. Other people can take relatively small amounts and get an ulcer right away.”

If your treatment requires taking NSAIDs over a long period, your doctor may also prescribe a common acid-reducing medication known as proton pump inhibitors, or PPIs, experts said. Some PPIs, such as Prilosec and Nexium, are over-the-counter medicines.

PPIs are highly effective at reducing your chances of developing ulcers and helping to heal them, Staller said, though they themselves have potentially serious long-term use risks and won’t protect against other possible negative effects of NSAIDs, including kidney failure.

Dingell said her decision to take Motrin didn’t lead to any other problems aside from the ulcer, but she urged people not to make the same mistake she did. The congresswoman has been sharing updates on her condition on her Facebook page; she said she doesn’t expect to leave the hospital until at least the end of this week because the hole in her stomach is still healing.

“As I have learned, NSAIDs have side effects and ignoring their potential impact isn’t a good idea,” she wrote in a recent Facebook post. “I am exhibit A.”

Moving forward, Dingell said, she hopes to use her experience to raise awareness about the potential dangers of over-the-counter medications. “I’m going to study and see how do we make sure people really do understand these dangers,” she said, adding: “We all need to be informed consumers and our own advocates.”