The majority of people in the U.S. manage health through at least one prescription drug. Drugs classified as non-antibiotics can adversely affect the gut microbiome and disrupt intestinal homeostasis. Here, we identified medications associated with an increased risk of GI infections across a population cohort of more than 1 million individuals monitored over 15 years. Notably, the cardiac glycoside digoxin and other drugs identified in this epidemiological study are sufficient to alter microbiome composition and risk of Salmonella enterica subsp. Typhimurium (S. Tm) infection in mice. The impact of digoxin treatment on S. Tm infection is transmissible via the microbiome, and characterization of this interaction highlights a digoxin-responsive β defensin that alters microbiome composition and consequent immune surveillance of the invading pathogen. Combining epidemiological and experimental approaches thus provides an opportunity to uncover drug-host-microbiome-pathogen interactions that increase infection risk in humans.