Heartburn: a topic worthy of several textbooks! Briefly, first make sure it’s not a heart attack (consult your health professional). Then understand that anything that relaxes the sphincter separating the contents of the stomach from the esophagus can lead to reflux, the backwashing of the acidic contents of the stomach into the esophagus, which does not enjoy being bathed in acid, so will experience pain, and occasionally spasm.
Many things can relax this sphincter, most of them enjoyable. Alcohol, tobacco, nicotine, overly distended stomachs from large meals, certain anti-hypertension drugs, certain illicit drugs, gravity boots, different neurologic conditions. And that’s just a few items on the list. Occasional reflux is generally due to indulgence in one of the first 4 items. Antacids such as bicarbonate, maalox, tums, rolaids, or pepto-bismol can produce rapid relief. Acid blockers which stop the stomach from producing hydrogen ions, like pepcid, zantac, tagament to name but a few, act slower, but generally last longer.
OF course it could also be (besides heart trouble), ulcer disease, pancreatitis, gallbladder inflammation, hepatitis, kidney stones, or a rupturing aortic aneurism. So anything not aided by simple antacids should probably be run past a competent health professional.
a health professional
Notice I didn’t claim to be a competent one:)