The lower esophageal sphincter, which is the valve between the stomach and the esophagus, may not close properly due to a hiatal hernia or GERD, allowing acid to enter the esophagus and gases to escape to the mouth. A Zenker's diverticulum may also result in halitosis due to aging food retained in the esophagus.
