The effects of the cellular environment on innate immunity remain poorly characterized. Here, we show that in Drosophila ATP-sensitive potassium channels (K(ATP)) mediate resistance to a cardiotropic RNA virus, Flock House virus (FHV). FHV viral load in the heart rapidly increases in K(ATP) mutant flies, leading to increased viremia and accelerated death. The effect of K(ATP) channels is dependent on the RNA interference genes Dcr-2, AGO2, and r2d2, indicating that an activity associated with this potassium channel participates in this antiviral pathway in Drosophila. Flies treated with the K(ATP) agonist drug pinacidil are protected against FHV infection, thus demonstrating the importance of this regulation of innate immunity by the cellular environment in the heart. In mice, the Coxsackievirus B3 replicates to higher titers in the hearts of mayday mutant animals, which are deficient in the Kir6.1 subunit of K(ATP) channels, than in controls. Together, our data suggest that K(ATP) channel deregulation can have a critical impact on innate antiviral immunity in the heart.