Nighttime Leg Cramp Causes
Nighttime leg cramps are common and mostly unexplained. StatPearls reports that they affect about 40% of adults older than 50 and 7% of children and adolescents aged 8 to 18. Around 40% of affected people get them three times a week, and 5% to 10% every night — enough to measurably cut sleep quality.
What is actually happening
The mechanism is abnormal excitation of the motor neurons that command the muscle, not a fault inside the muscle itself. Among the physiologic triggers StatPearls lists, the one that fits the night pattern is positioning during work or sleep — the calf held in a shortened position for hours. But idiopathic nocturnal cramps are a named category precisely because most of the time no cause is found. The full mechanism is in muscle cramp causes, and the reason the calf is the usual target in calf cramp: causes.
Causes worth ruling out
Not everything that cramps at night is idiopathic. StatPearls associates nocturnal cramps with peripheral vascular disease, venous insufficiency, restless legs syndrome, periodic limb movements of sleep, obstructive sleep apnea, pregnancy, diabetes and thyroid disease. Chronic obstructive pulmonary disease is named as the underlying cause in 30% of nocturnal cramp cases. Diuretics, statins, long-acting beta agonists and oral contraceptives appear on the medication list.
The stretching protocol that was studied
Some studies show benefit from posterior leg muscle stretching in people with nocturnal cramps. The protocol as described: stand with the feet flat on the floor and lean forward for 20 seconds, repeat 4 times, performed 3 to 4 times per day, typically in the evening and once before bed. Alongside it: keep bed linens loose at the foot of the bed so the foot is not pushed into pointing, avoid long periods of immobility, and use supportive footwear.
Magnesium does not fix this
This is where popular advice and evidence part ways. The 2020 Cochrane review of magnesium for skeletal muscle cramps found no difference against placebo in older adults — a risk ratio of 1.04 (95% CI 0.84 to 1.29) for the proportion of people whose cramp frequency improved by at least a quarter, rated high-certainty evidence. Minor adverse events, mostly gastrointestinal, were more common in the magnesium group. The authors’ conclusion: clinically meaningful cramp prophylaxis from magnesium in older adults is unlikely.
When to see a doctor
Seek evaluation if cramps repeatedly disrupt sleep, are severe, or do not respond to stretching, and especially if they come with persistent muscle weakness, swelling, dark-colored urine or numbness. Quinine, once widely prescribed for night cramps, is no longer recommended because of the risk of serious adverse events.
This content is informational and does not replace medical consultation, diagnosis, or treatment.
Frequently asked questions
Why do leg cramps happen at night while sleeping?
The mechanism described in StatPearls is abnormal firing of motor neurons, with positioning during sleep listed among the physiologic triggers — the calf held shortened for hours. Most nocturnal cramps are idiopathic: no cause is identified at all.
How common are night cramps, and at what age?
StatPearls reports that nocturnal leg cramps affect about 40% of adults older than 50 and 7% of children and adolescents aged 8 to 18. Around 40% of those affected have symptoms three times a week, and 5% to 10% every night.
Does magnesium prevent nighttime leg cramps?
No, not in older adults. The 2020 Cochrane review found magnesium no better than placebo — a risk ratio of 1.04 (95% CI 0.84 to 1.29) for the proportion of people whose cramps improved, rated high-certainty evidence. The authors concluded that clinically meaningful benefit is unlikely in this group.
What can I do to have them less often?
The stretch studied for nocturnal cramps: stand with the feet flat on the floor, lean forward for 20 seconds, repeat 4 times, done 3 to 4 times a day including once before bed. Keeping bed linens loose at the foot of the bed, to stop the foot from pointing, is also listed.
Sources
- Bordoni B, Goldin J, Sugumar K. Muscle Cramps. StatPearls, NCBI Bookshelf (updated 2025)
- Garrison SR et al. Magnesium for skeletal muscle cramps. Cochrane Database of Systematic Reviews, 2020
- Muscle cramps — MedlinePlus Medical Encyclopedia (A.D.A.M., Inc.)
Written by Lucas Silva · Reviewed by Lucas Silva · Updated on August 14, 2026