Previous studies have demonstrated the negative impacts of ostracism on primary needs and moods, particularly children and adolescents. Given children’s early exposure to the Internet, online ostracism could potentially affect their primary needs and moods at an earlier age. To investigate this, the present study utilized the Cyberball paradigm to manipulate the exclusion and re-inclusion and examined the threats to primary needs (sense of belonging, self-esteem, control, meaningful existence) and emotions (happiness, sadness, anger) in school-aged children (163 children aged 6-8, 8-10, and 10-11) following social exclusion and subsequent inclusion. The findings revealed that the threats to the four primary needs due to ostracism began to emerge around the age of 8-10 years and persisted until the age of 10-12 years. Regarding moods, the negative effects of ostracism appeared from the age of 6-8 years and worsened with age. This suggests the existence of a critical period during which ostracism poses a threat to children’s primary needs and has adverse effects on their moods. Moreover, the study demonstrated that brief inclusion following exclusion effectively restores the primary needs and moods of ostracized children. These findings provide insights into how to support children in recovering from the negative effects of ostracism.