The transcription factor MEF2 acts as a central switch between metabolic and immune functions in Drosophila, shifting upon infection from activation of anabolic enzymes to immune response genes. Here, MEF2A is linked to infection.