To our knowledge, this is the first study to demonstrate that HEX plays a protective role in mastitis caused by dysbiosis and infection, thereby serving as a reference for the prevention of mastitis and other infectious and metabolic diseases. This evidence concerns the gene HHEX and infection.