Quinolinic carboxylic acids are known for their metal ion chelating properties in insects, plants and bacteria. The larval stages of the lepidopteran pest, Spodoptera littoralis, produce 8-hydroxyquinoline-2-carboxylic acid (8-HQA) in high concentrations from tryptophan in the diet. At the same time, the larval midgut is known to harbor a bacterial population. The motivation behind the work was to investigate whether 8-HQA is controlling the bacterial community in the gut by regulating the concentration of metal ions. Knocking out the gene for kynurenine 3-monooxygenase (KMO) in the insect using CRISPR/Cas9 eliminated production of 8-HQA and significantly increased bacterial numbers and diversity in the larval midgut. Adding 8-HQA to the diet of knockout larvae caused a dose-dependent reduction of bacterial numbers with minimal effects on diversity. Enterococcus mundtii dominates the community in all treatments, probably due to its highly efficient iron uptake system and production of the colicin, mundticin. Thus host factors and bacterial properties interact to determine patterns of diversity and abundance in the insect midgut.