Bacterial porins permit permeation of hydrophilic nutrients and antibiotics across the outer membrane but also contribute to proton leak from the periplasmic space, suggesting that their activity might be dynamically regulated. Here we show, in Escherichia coli, that porin permeability is controlled by changes in periplasmic ions, inhibited by periplasmic acidification, thereby limiting proton loss during electron transport chain activity, and enhanced during starvation, promoting nutrient uptake. Growth in glucose increases periplasmic potassium through activating the voltage-gated channel Kch, triggering enhanced porin permeation and membrane action potentials. This metabolic control of porin permeability explains the recognized decrease in antibiotic susceptibility when bacteria are grown in lipid media and the impact of mutations in central metabolism genes on drug resistance, identifying Kch as a therapeutic target to improve bacterial killing by antibiotics.