The ventilating device is for a housing with a ventilation opening (2) in a housing wall (5). The device is arranged to divert fluid or moisture away. The device has a cap (6) with a base plate (7). The base plate (7) has an outer edge flange (4) going away from the housing wall (1). The flange (4) surrounds conducting walls (5). The flange (4) and walls (5) are arranged in a labyrinth arrangement. The housing wall (1) has recesses (3) which tightly hold the free edge regions of the flange (4) and the walls (5). The ventilation opening (2) on the housing wall side and another ventilation opening (8) on the cap side are provided at different ends of the labyrinth.