In recent years, the incidence of food allergies in children has been increasing annually, significantly affecting the quality of life for patients and their families. It has long been suspected that childhood allergies might potentially lead to behavioral and psychological issues in adulthood, but the specific connection remains unclear. In this study, we established a model of young mice allergic to milk αS1-casein, conducted behavioral tests, and employed transcriptomics, immunohistochemistry, Golgi staining, and fecal microbiota transplantation to explore the link between early life allergies and adult psychological problems. The results showed that early life milk protein allergy significantly increased intestinal epithelial permeability in mice, leading to the translocation of gut microbiota metabolites. This process subsequently activated astrocyte lysosomes via SLC15a3, making astrocytes more susceptible. This susceptibility caused mice with early life milk protein allergy to have more activated astrocytes and excessive dendritic spine phagocytosis (normal group: 5.4 ± 1.26 spines/10 μm, allergy group: 3.2 ± 0.92 spines/10 μm) under acute stress in adulthood, leading to anxiety and depressive behaviors.