Differentiation of niche by means of resource partitioning facilitates coexistence of species with similar requirements. Here we analyse the association between different habitats (i.e. nest types) and two Diptera species of the poorly known Family Carnidae that coexist during their larval and pupal stage in the nests of troglodytic bird species. We also describe for the first time the puparium of Hemeromyia anthracina and Hemeromyia longirostris and offer morphometric data of the puparia of these two species and of Carnus hemapterus. Both the smaller size and the occurrence of well-developed spiracles allow easy discrimination of the puparium of C. hemapterus. The puparia of both Hemeromyia species is very similar and only differ in the distance between the small spiracles. Hemeromyia anthracina and C. hemapterus coexisted in nest boxes but the former species did not occur in natural sandy cavities where, in turn, C. hemapterus was highly prevalent. Carnus hemapterus prevalence did not differ between nest boxes and natural cavities but its abundance was higher in the first type of nest. This study shows clear associations of the two dipteran species with specific types of nests. Yet, some conditions are seemingly acceptable for both species.