Fever is a common symptom of influenza and coronavirus disease 2019 (COVID-19), yet its physiological role in host resistance to viral infection remains less clear. Here, we demonstrate that exposure of mice to the high ambient temperature of 36 °C increases host resistance to viral pathogens including influenza virus and severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). High heat-exposed mice increase basal body temperature over 38 °C to enable more bile acids production in a gut microbiota-dependent manner. The gut microbiota-derived deoxycholic acid (DCA) and its plasma membrane-bound receptor Takeda G-protein-coupled receptor 5 (TGR5) signaling increase host resistance to influenza virus infection by suppressing virus replication and neutrophil-dependent tissue damage. Furthermore, the DCA and its nuclear farnesoid X receptor (FXR) agonist protect Syrian hamsters from lethal SARS-CoV-2 infection. Moreover, we demonstrate that certain bile acids are reduced in the plasma of COVID-19 patients who develop moderate I/II disease compared with the minor severity of illness group. These findings implicate a mechanism by which virus-induced high fever increases host resistance to influenza virus and SARS-CoV-2 in a gut microbiota-dependent manner.