Human milk oligosaccharides (hMOs) and non-digestible carbohydrates (NDCs) are known to inhibit the adhesion of pathogens to the gut epithelium, but the mechanisms involved are not well understood. Here, the effects of 2 '-FL, 3-FL, DP3-DP10, DP10-DP60 and DP30-DP60 inulins and DM7, DM55 and DM69 pectins were studied on pathogen adhesion to Caco-2 cells. As the growth phase influences virulence, E. coli ET8, E. coli LMG5862, E. coli O119, E. coli WA321, and S. enterica subsp. enterica LMG07233 from both log and stationary phases were tested. Specificity for enteric pathogens was tested by including the lung pathogen K. pneumoniae LMG20218. Expression of the cell membrane glycosylation genes of galectin and glycocalyx and inflammatory genes was studied in the presence and absence of 2 '-FL or NDCs. Inhibition of pathogen adhesion was observed for 2 '-FL, inulins, and pectins. Pre-incubation with 2 '-FL downregulated ICAM1, and pectins modified the glycosylation genes. In contrast, K. pneumoniae LMG20218 downregulated the inflammatory genes, but these were restored by pre-incubation with pectins, which reduced the adhesion of K. pneumoniae LMG20218. In addition, DM69 pectin significantly upregulated the inflammatory genes. 2 '-FL and pectins but not inulins inhibited pathogen adhesion to the gut epithelial Caco-2 cells through changing the cell membrane glycosylation and inflammatory genes, but the effects were molecule-, pathogen-, and growth phase-dependent.