Mental health during adolescence can affect an individual’s long-term quality of life. However, the effects of family and school contexts on students’ mental health have been little explored. This study aims to analyze the relationships between family and school life and feelings of loneliness and trouble sleeping owing to worries in adolescents. The data from this cross-sectional study were obtained from Brazil’s National School Health Survey (PeNSE), which obtained its data through questionnaires. This study’s sample consisted of 102,072 ninth-grade students aged between 11 and 19 years, 52,782 (51.7%) of whom were female, enrolled in public and private schools throughout Brazil. The methodology consisted of an analysis using the Poisson regression model. Regarding the family context, mental health issues were associated with hunger, distant relationships with parents, and family violence. Regarding the school context, feelings of loneliness and trouble sleeping were associated with poor peer relationships, insecurity at school, and schools in more violent areas. This study contributes to the elaboration of public policies aimed at bringing awareness to family members and school bodies that indicators of mental health in adolescents are influenced by the quality of bonds established within these environments.