People who take heartburn drugs such as Prilosec and Nexium may be at increased risk of two potentially serious gut infections, a new study suggests.

The study, of nearly 565,000 adults, found those on certain heartburn drugs had higher risks of infection with C. difficile and Campylobacter bacteria.

Both bugs cause abdominal pain and diarrhea, but can become more serious -- especially C. diff. According to the U.S. Centers for Disease Control and Prevention, almost half a million Americans were sickened by the infection in 2011, and 29,000 of them died within a month.

Get Breaking News Delivered to Your Inbox

The heartburn drugs in question included both proton pump inhibitors (PPIs) -- brands like Prilosec, Prevacid and Nexium -- and H2 blockers, such as Zantac, Pepcid and Tagamet, the study authors said.

All suppress stomach acid production, and the researchers suspect that may make some people more vulnerable to gastrointestinal infections.

The new findings, published Jan. 5 in the British Journal of Clinical Pharmacology, aren’t the first to raise such concerns.

The U.S. Food and Drug Administration has already warned about a risk of C. diff infection linked to proton pump inhibitors.

“This study offers more evidence that there’s an association,” said Dr. F. Paul Buckley, surgical director of the Heartburn and Acid Reflux Center at the Scott & White Clinic in Round Rock, Texas.

Buckley, who was not involved in the study, said it’s also important to see the results in a bigger context. Long-term use of PPIs, in particular, has been tied to a number of health risks, including nutrient deficiencies, bone loss and heart attack, he said.

Because PPIs are so common and available over-the-counter, people may assume they’re “100 percent safe,” Buckley pointed out.

“There’s still a myth that these drugs are benign,” he said. “It’s not true.”

The new findings don’t actually prove that either PPIs or H2 blockers raised the risk of gut infections.

But it is plausible, according to the researchers, led by Dr. Thomas MacDonald, a professor of pharmacology at the University of Dundee in Scotland.

They suspect that drugs that suppress stomach acids can change the balance of “good” and “bad” bacteria in the gut, which may make people more susceptible to infections.

Dr. David Bernstein, a gastroenterologist who was not involved in the study, agreed that stomach acid suppression could be the culprit.

But he also stressed that heartburn medications alone do not directly cause gut infections.

For one, C. diff most often strikes people who are sick and on prolonged courses of antibiotics. And Campylobacter infections are foodborne -- usually caused by eating raw or undercooked poultry, or foods contaminated by those products.

“So it’s not just that you take a PPI and you get C. diff,” said Bernstein, who is chief of hepatology at Northwell Health in Manhasset, N.Y.

Still, he said, patients and doctors should be aware that the drugs might contribute to the risk of certain infections.

For the study, MacDonald’s team analyzed medical records from close to 565,000 Scottish adults. More than 188,000 had been given at least one prescription for a PPI or H2 blocker; the rest had no prescriptions for the drugs, researchers said.

On average, people on the drugs were roughly four times more likely to develop a Campylobacter infection between 1999 and 2013.

They were also 70 percent more likely to be diagnosed with C. diff outside of a hospital. Their odds of being diagnosed in the hospital were 42 percent higher.

The researchers accounted for other factors, such as people’s age and medical history. And they still found an association between the heartburn medications and higher infection risks.

Bernstein stressed that the study is reporting group averages.

“The risk to any individual patient would actually be quite small,” he said.

But people should be sure they truly need a PPI or H2 blocker before taking one, Bernstein said.

“And you should be reassessed over time, to see if you really need to continue the medication,” he added. “The potential problems are with long-term use.”

Buckley made the same point. Even if a doctor prescribes a PPI, he said, ask questions. “Ask why it’s being prescribed, and whether there are any alternatives,” he advised.

H2 blockers are one alternative, Buckley said. Even though this study tied them to gut infections, he said, the drugs don’t seem to carry the other risks linked to PPIs, including heart problems.

People with only occasional heartburn don’t need PPIs at all, Buckley said. They may do well with diet and lifestyle changes alone.

For people with more severe acid reflux, he said, surgery might be an option.