SummaryHuman genetic diversity can reveal critical factors in host-pathogen interactions. This is especially useful for human-restricted pathogens likeSalmonella entericaserovar Typhi (S.Typhi), the cause of typhoid fever. One key defense during bacterial infection is nutritional immunity: host cells attempt to restrict bacterial replication by denying bacteria access to key nutrients or supplying toxic metabolites. Here, a cellular genome-wide association study of intracellular replication byS. Typhi in nearly a thousand cell lines from around the world—and extensive follow-up using intracellularS.Typhi transcriptomics and manipulation of magnesium availability—demonstrates that the divalent cation channel mucolipin-2 (MCOLN2 or TRPML2) restrictsS.Typhi intracellular replication through magnesium deprivation. Mg2+currents, conducted through MCOLN2 and out of endolysosomes, were measured directly using patch-clamping of the endolysosomal membrane. Our results reveal Mg2+limitation as a key component of nutritional immunity againstS.Typhi and as a source of variable host resistance.