Social insects have evolved an array of individual and social behaviours that limit pathogen entrance and spread within the colony. The detection of ectoparasites or of fungal spores on a nestmate body triggers their removal by allogrooming and appears as a primary component of social prophylaxis. However, in the case of fungal infection, one may wonder whether ant workers are able to detect, discriminate and keep at bay diseased nestmates that have no spores over their cuticle but which constitute a latent sanitary risk due to post-mortem corpse sporulation. Here, we investigate the ability of Myrmica rubra workers to detect and discriminate a healthy from a diseased nestmate infected by the entomopathogen Metarhizium anisopliae. During dyadic encounters in a neutral location, workers were more aggressive towards isolated sick nestmates on the 3rd post-infection day. However, no such detection or discrimination of fungus-infected nestmates occurred in a social context inside the nest or at the nest entrance. Gatekeepers never actively rejected incoming diseased nestmates that rather spontaneously isolated themselves outside the nest. Our study reveals that ant workers may detect health-dependent cues and that their 'acceptance level' of sick nestmates is tunable depending on the social context. This raises questions about possible trade-offs between a social closure to pathogens and risks of erroneous rejection of healthy nestmates. Social isolation of moribund ants also appears as a widespread prophylactic strategy of social insects allowing them to reduce exposure to pathogens and to spare costs associated with the management of infected individuals.