Heartburn occurs when acidic digestive juices in your stomach splash up into your esophagus, the passageway between your throat and stomach. Your stomach has a special lining that protects it from those acids, but your esophagus doesn’t. That can cause an uncomfortable burning sensation in your chest, and possibly a sour taste in your mouth.
In some people, this happens because the valve between the esophagus and stomach (called the lower esophageal sphincter) isn’t working properly. Normally that valve seals shut after opening. But it can become relaxed and not close tightly, letting juices escape your stomach and seep up into the esophagus.