Detrimental effects of ultraviolet (UV) light on living organisms are well understood, little is known about the effects of blue light irradiation. Although a recent study revealed that blue light caused more harmful effects on insects than UV light and blue light irradiation killed insect pests of various orders including Diptera, the effects of blue light on physiology of insects are still largely unknown. Here we studied the effects of blue light irradiation on cuticular melanin in larval and the immune response in adult stage of Bactrocera dorsalis. We also evaluated the effects of blue light exposure in larval stage on various age and mass at metamorphosis and the mediatory role of cuticular melanin in carryover effects of larval stressors across metamorphosis. We found that larvae exposed to blue light decreased melanin contents in their exoskeleton with smaller mass and delayed metamorphosis than insects reared without blue light exposure. Across metamorphosis, lower melanotic encapsulation response and higher susceptibility to Beauveria bassiana was detected in adults that had been exposed to blue light at their larval stage, thereby constituting the first evidence that blue light impaired adult immune function in B. dorsalis as a carryover effect of larval exposure.