Innate immune responses to pathogens are governed by the nervous system. Here, we investigated the molecular mechanism underlying innate immunity in Caenorhabditis elegans against Escherichia coli OP50, a standard laboratory C. elegans food. Longevity was compared in worms fed live or UV-killed OP50 at low or high density food condition (HDF). Expression of the antimicrobial gene lys-8 was approximately 5-fold higher in worms fed live OP50, suggesting activation of innate immunity upon recognition of OP50 metabolites. Lifespan was extended and SOD-3 mRNA levels were increased in gpa-9-overexpressing gpa-9XS worms under HDF in association with robust induction of insulin/IGF-1 signaling (IIS). Expression of ins-7 and daf-28 that control lys-8 expression was reduced in gpa-9XS, indicating that GPA-9-mediated immunity is due in part to ins-7 and daf-28 downregulation. Our results suggest that OP50 metabolites in amphid neurons elicit innate immunity through the IIS pathway, and identify GPA-9 as a novel regulator of both the immune system and aging in C. elegans.