A major cost of group-living is its inherent risk of pathogen infection. To limit this risk, many group-living animals have developed the capability to prophylactically boost their immune system in the presence of group members and/or to mount collective defences against pathogens. These two phenomena, called density-dependent prophylaxis and social immunity, respectively, are often used to explain why, in group-living species, individuals survive better in groups than in isolation. However, this survival difference may also reflect an alternative and often overlooked process: a cost of social isolation on individuals' capability to fight against infections. Here, we disentangled the effects of density-dependent prophylaxis, social immunity and stress of social isolation on the survival after pathogen exposure in group-living adults of the European earwig Forficula auricularia. By manipulating the presence of group members both before and after pathogen exposure, we demonstrated that the cost of being isolated after infection, but not the benefits of social immunity or density-dependent prophylaxis, explained the survival of females. Specifically, females kept constantly in groups or constantly isolated had higher survival rates than females that were first in groups and then isolated after infection. Our results also showed that this cost of social isolation was absent in males and that social isolation did not reduce the survival of noninfected individuals. Overall, this study gives a new perspective on the role of pathogens in social evolution, as it suggests that an apparently nonadaptive, personal immune process may promote the maintenance of group-living under pathogenic environments.