Organisms in the wild are constantly faced with a wide range of environmental variability, such as fluctuation in food availability. Poor nutritional conditions influence life-histories via individual resource allocation patterns, and trade-offs between competing traits. In this study, we assessed the influence of food restriction during development on the energetically expensive traits flight metabolic rate (proxy of dispersal ability), encapsulation rate (proxy of immune defence), and lifespan using the Glanville fritillary butterfly, Melitaea cinxia, as a model organism. Additionally, we examined the direct costs of flight on individual immune function, and whether those costs increase under restricted environmental conditions. We found that nutritional restriction during development enhanced adult encapsulations rate, but reduced both resting and flight metabolic rates. However, at the individual level metabolic rates were not associated with encapsulation rate. Interestingly, individuals that were forced to fly prior to the immune assays had higher encapsulation rates than individuals that had not flown, suggesting that flying itself enhances immune response. Finally, in the control group encapsulation rate correlated positively with lifespan, whereas in the nutritional restriction group there was no relationship between these traits, suggesting that the association between encapsulation rate on adult lifespan was condition-dependent. Thus stressful events during both larval development (food limitation) and adulthood (forced flight) induce increased immune response in the adult butterflies, which may allow individuals to cope with stressful events later on in life.