Heartburn occurs when the lower esophageal sphincter, the muscle at the junction of the esophagus and stomach, is weakened or put under too much pressure. This causes it to slacken or stay open, and the acidity produced by the stomach backs up into the esophagus and irritates it, causing a burning sensation.
https://www.themountaineer.com/life/health/what-if-you-could-find-a-solution-for-heartburn/article_9728c284-5702-11e9-92c0-8f980dbd8c84.html