Heat stress impacts the immune system of dairy animals by altering the hypothalamic-pituitary-adrenal axis and thyroid function, leading to conditions such as hypothyroidism and hypercortisolism. This study aimed to elucidate the effect of hypothyroidism and hypercortisolism on the response of mammary innate immune function to inflammation caused by Escherichia coli in dairy goats. To induce hypothyroidism and hypercortisolism, we administered 6-n-propyl-2-thiouracil (PTU; for 21 days) and dexamethasone (DEX; for 5days), respectively, to six goats each; six goats without treatment were used as the control group. After treatment, lipopolysaccharide (LPS) from E. coli O111 was infused into the mammary gland. Somatic cell counts (SCC) and levels of lactoferrin (LF), S100A7, immunoglobulin A (IgA), and interleukin-8 (IL-8) in milk until 7days after LPS infusion were measured. An increase in SCC after LPS infusion was inhibited in both PTU and DEX groups, and an increase in LF after LPS infusion was inhibited in PTU group, compared with that in the control group. The results of the present study suggest that the recruitment of neutrophils and LF production decreased under hypothyroidism or hypercortisolism, which may be one of the causes underlying increased incidence of mastitis in dairy animals under heat stress conditions.