The mucosal surfaces are often the first site of interaction between pathogenic microorganisms and the host. Activation of the mucosal immune response has the important function of containing an infection and preventing dissemination of pathogens to systemic sites (barrier function). Numerous lines of evidence suggest that the barrier function is orchestrated by a subset of cytokines (interleukin (IL-)17 and IL-22), which belong to the Th17 family. IL-17 and IL-22 induce expression of antimicrobial peptides and neutrophil chemoattractants at mucosal sites, and thus play an important role in controlling mucosal infections. However, there is increasing evidence that mucosal pathogens achieve greater colonization during inflammation because they are resistant to a subset of these antimicrobial responses. In this review we compare the antimicrobial responses elicited by Th17 cytokines during mucosal infections with four different pathogens: Klebsiella pneumoniae, Citrobacter rodentium, Candida albicans and Salmonella typhimurium. We will then discuss which responses may constitute the mucosal barrier, thus providing a benefit to the host, and which ones may promote the colonization of pathogens, thereby providing a benefit to the microbes.