Locomotion is crucial for the survival of living organisms, as it allows foraging, flight and mating behaviour. In response to environmental cues, many organisms switch between alternative forms of locomotion, referred to as gaits. The nematode Caenorhabditis elegans exhibits two gaits: swimming in liquids and crawling on dense gels. The kinematics and patterns of muscle activity differ between the two gaits, with swimming being less efficient than crawling. We found that C. elegans when grown on dietary restriction (DR) plates and then tested immediately for swimming activity exhibit an accelerated frequency of body-bending swimming compared with ad libitum-fed worms, resulting in an increased swimming speed. This response is independent of the presence or absence of food bacteria in the assay liquid. In contrast, the crawling speed of DR worms on assay agar plates is decreased and influenced by food availability. Because DR also attenuates the disturbed swimming activity of worms that are deficient in the presynaptic dopamine transporter DAT-1, our data link DR-induced alterations of the swimming gait to synaptic processes. This strongly suggests a biochemical rather than a biomechanical response to DR provoked by changes in the worm's body structure. We conclude that the increase in locomotor activity in response to DR is specific to the swimming gait and might represent a survival strategy, allowing food-deprived nematodes to exit unfavourable environments.