Heart failure (HF) is an increasing global health crisis, affecting 40 million people and causing 50% mortality within 5 years of diagnosis. A fuller understanding of the genetic and environmental factors underlying HF, and novel therapeutic approaches to address it, are urgently warranted. Here, we discovered that cardiac-specific germline deletion in mice of potassium channel β subunit-encoding Kcne2 (Kcne2CS-/- ) causes dilated cardiomyopathy and terminal HF (median longevity, 28 weeks). Mice with global Kcne2 deletion (Kcne2Glo-/- ) exhibit multiple HF risk factors, yet, paradoxically survived over twice as long as Kcne2CS-/- mice. Global Kcne2 deletion, which inhibits gastric acid secretion, reduced the relative abundance of species within Bacteroidales, a bacterial order that positively correlates with increased lifetime risk of human cardiovascular disease. Strikingly, the proton-pump inhibitor omeprazole similarly altered the microbiome and delayed terminal HF in Kcne2CS-/- mice, increasing survival 10-fold at 44 weeks. Thus, genetic or pharmacologic induction of hypochlorhydria and decreased gut Bacteroidales species are associated with lifespan extension in a novel HF model.