Innate lymphoid cells (ILCs) and CD4+ T cells produce IL-22, which is critical for intestinal immunity. The microbiota is central to IL-22 production in the intestines; however, the factors that regulate IL-22 production by CD4+ T cells and ILCs are not clear. Here, we show that microbiota-derived short-chain fatty acids (SCFAs) promote IL-22 production by CD4+ T cells and ILCs through G-protein receptor 41 (GPR41) and inhibiting histone deacetylase (HDAC). SCFAs upregulate IL-22 production by promoting aryl hydrocarbon receptor (AhR) and hypoxia-inducible factor 1α (HIF1α) expression, which are differentially regulated by mTOR and Stat3. HIF1α binds directly to the Il22 promoter, and SCFAs increase HIF1α binding to the Il22 promoter through histone modification. SCFA supplementation enhances IL-22 production, which protects intestines from inflammation. SCFAs promote human CD4+ T cell IL-22 production. These findings establish the roles of SCFAs in inducing IL-22 production in CD4+ T cells and ILCs to maintain intestinal homeostasis.