Social insects such as ants have evolved collective rather than individual immune defence strategies against diseases and parasites at the level of their societies (colonies), known as social immunity. Ants frequently host other arthropods, so-called myrmecophiles, in their nests. Here, we tested the hypothesis that myrmecophily may partly arise from selection for exploiting the ants' social immunity. We used larvae of the wax moth Galleria mellonella as 'model myrmecophiles' (baits) to test this hypothesis. We found significantly reduced abundance of entomopathogens in ant nests compared with the surrounding environment. Specific entomopathogen groups (Isaria fumosorosea and nematodes) were also found to be significantly less abundant inside than outside ant nests, whereas one entomopathogen (Beauveria brongniartii) was significantly more abundant inside nests. We therefore hypothesize that immunological benefits of entering ant nests may provide us a new explanation of why natural selection acts in favour of such a life-history strategy.