Gut microbes in insects may play an important role in the digestion, immunity and protection, detoxification of toxins, development, and reproduction. The rice leaffolder Cnaphalocrocis medinalis (Guenée) (Lepidoptera: Crambidae) is a notorious insect pest that can damage rice, maize, and other gramineous plants. To determine the effects of host plants and generations on the gut microbiota of C. medinalis, we deciphered the bacterial configuration of this insect pest fed rice or maize for three generations by Illumina MiSeq technology. A total of 16 bacterial phyla, 34 classes, 50 orders, 101 families, 158 genera, and 44 species were identified in C. medinalis fed rice or maize for three generations. Host plants, insect generation, and their interaction did not influence the alpha diversity indices of the gut microbiota of C. medinalis. The dominant bacterial taxa were Proteobacteria and Firmicutes at the phylum level and Enterococcus and unclassified Enterobacteriaceae at the genus level. A number of twenty genera coexisted in the guts of C. medinalis fed rice or maize for three generations, and their relative abundances occupied more than 90% of the gut microbiota of C. medinalis. A number of two genera were stably found in the gut of rice-feeding C. medinalis but unstably found in the gut microbiota of maize-feeding C. medinalis, and seven genera were stably found in the gut of maize-feeding C. medinalis but unstably found in the gut of rice-feeding C. medinalis. In addition, many kinds of microbes were found in some but not all samples of the gut of C. medinalis fed on a particular host plant. PerMANOVA indicated that the gut bacteria of C. medinalis could be significantly affected by the host plant and host plant × generation. We identified 47 taxa as the biomarkers for the gut microbiota of C. medinalis fed different host plants by LEfSe. Functional prediction suggested that the most dominant role of the gut microbiota in C. medinalis is metabolism, followed by environmental information processing, cellular processes, and genetic information processing. Our findings will enrich the understanding of gut bacteria in C. medinalis and reveal the differences in gut microbiota in C. medinalis fed on different host plants for three generations.