Chronic inflammation predisposes to aging-associated disease, but it is unknown whether immunity regulation might be important for extending healthy lifespan. Here we show that in C. elegans, dietary restriction (DR) extends lifespan by modulating a conserved innate immunity pathway that is regulated by p38 signaling and the transcription factor ATF-7. Longevity from DR depends upon p38-ATF-7 immunity being intact but downregulated to a basal level. p38-ATF-7 immunity accelerates aging when hyperactive, influences lifespan independently of pathogen exposure, and is activated by nutrients independently of mTORC1, a major DR mediator. Longevity from reduced insulin/IGF-1 signaling (rIIS) also involves p38-ATF-7 downregulation, with signals from DAF-16/FOXO reducing food intake. We conclude that p38-ATF-7 is an immunometabolic pathway that senses bacterial and nutrient signals, that immunity modulation is critical for DR, and that DAF-16/FOXO couples appetite to growth regulation. These conserved mechanisms may influence aging in more complex organisms.