Human genetic diversity can reveal critical factors in host-pathogen interactions. This is especially useful for human-restricted pathogens like Salmonella enterica serovar Typhi (S. Typhi) the cause of Typhoid fever. One key dynamic during infection is competition for nutrients: host cells attempt to restrict intracellular replication by depriving bacteria of key nutrients or delivering toxic metabolites in a process called nutritional immunity. Here a cellular genome-wide association study of intracellular replication by S. Typhi in nearly a thousand cell lines from around the world and extensive follow-up using intracellular S. Typhi transcriptomics and manipulation of magnesium concentrations demonstrates that the divalent cation channel mucolipin-2 (MCOLN2) restricts S. Typhi intracellular replication through magnesium deprivation. Our results reveal natural diversity in Mg2+ limitation as a key component of nutritional immunity against S. Typhi.