Larval and adult fruit flies are attracted to volatiles emanating from food substrates that have been occupied by larvae. We tested whether such volatiles are emitted by the larval gut bacteria by conducting tests under bacteria-free (axenic) conditions. We also tested attraction to two bacteria species, Lactobacillus brevis, which we cultured from larvae in our lab, and L. plantarum, a common constituent of fruit flies' microbiome in other laboratory populations and in wild fruit flies. Neither larvae nor adults showed attraction to axenic food that had been occupied by axenic larvae, but both showed the previously reported attraction to standard food that had been occupied by larvae with an intact microbiome. Larvae also showed significant attraction to volatiles from axenic food and larvae to which we added only either L. brevis or L. plantarum, and volatiles from L. brevis reared on its optimal growth medium. Controlled learning experiments indicated that larvae experienced with both standard and axenic used food do not perceive either as superior, while focal larvae experienced with simulated used food, which contains burrows, perceive it as superior to unused food. Our results suggest that flies rely on microbiome-derived volatiles for long-distance attraction to suitable food patches. Under natural settings, fruits often contain harmful fungi and bacteria, and both L. brevis and L. plantarum produce compounds that suppress the growth of some antagonistic fungi and bacteria. The larval microbiome volatiles may therefore lead prospective fruit flies towards substrates with a hospitable microbial environment.