Pathogen avoidance behaviours are often assumed to be an adaptive host defence. However, there is limited experimental data on heritable, intrapopulation phenotypic variation for avoidance, a strong prerequisite for adaptive responses to selection. We investigated trophic pathogen avoidance in 122 inbred Drosophila melanogaster lines, and in a derived outbred population. Using the FlyPAD system, we tracked the feeding choice that flies made between substrates that were either clean or contained a bacterial pathogen. We uncovered significant, but weakly heritable variation in the preference index amongst fly lines. However, instead of avoidance, most lines demonstrated a preference for substrates containing several bacterial pathogens, showing avoidance only for extremely high bacterial concentrations. Bacterial preference was not associated with susceptibility to infection and was retained in flies with disrupted immune signalling. Phenotype–genotype association analysis indicated several novel genes (CG2321, CG2006, and ptp99A) associated with increased preference for the bacterial substrate, while the amino‐acid transporter sobremesa was associated with greater aversion. Given the known fitness benefits of consuming high‐protein diets, our results suggest that bacterial attraction may instead reflect a dietary preference for protein over carbohydrate. More work quantifying intrapopulation variation in avoidance behaviours is needed to fully assess its importance in host–pathogen evolutionary ecology.