Tribolium castaneum (Herbst), which resides in shaded areas avoiding daylight, has developed various adaptation strategies to cope with ultraviolet (UV) stress. In this study, we utilized 16S rRNA amplicon sequencing to assess the diversity of the bacterial communities within T. castaneum following exposure to ultraviolet-A and ultraviolet-B for different durations, and to elucidate the role of microbiome in host response to UV stress. This study revealed that UV irradiation affected the relative abundance of bacterial community within T. castaneum, rather than its species richness. The significant differences were observed in the relative abundance of Proteobacteria and Cyanobacteria, among the comparison of UV irradiation groups at phylum level. Most genes coded by bacteria were annotated on membrane transport, replication and repair, amino acid metabolism, energy metabolism and carbohydrate metabolism with reference to Kyoto Encyclopedia of Genes and Genomes database. However, the significant differences identified in this study were limited, making it challenging to establish a clear relationship between UV irradiation and the bacteria within T. castaneum larvae. Consequently, we propose the viewpoint that the role of bacteria in contributing T. castaneum against UV stress may have been diminished during their development due to the low-UV rearing conditions.