During aging, innate immunity progresses to a chronically active state. However, what distinguishes those that "age well" from those developing age-related neurological conditions is unclear. We used Drosophila to explore the cost of immunity in the aging brain. We show that mutations in intracellular negative regulators of the IMD/NF-κB pathway predisposed flies to toxic levels of antimicrobial peptides, resulting in early locomotor defects, extensive neurodegeneration, and reduced lifespan. These phenotypes were rescued when immunity was suppressed in glia. In healthy flies, suppressing immunity in glial cells resulted in increased adipokinetic hormonal signaling with high nutrient levels in later life and an extension of active lifespan. Thus, when levels of IMD/NF-κB deviate from normal, two mechanisms are at play: lower levels derepress an immune-endocrine axis, which mobilizes nutrients, leading to lifespan extension, whereas higher levels increase antimicrobial peptides, causing neurodegeneration. Immunity in the fly brain is therefore a key lifespan determinant.