What Causes Leg Cramps at Night and How to Prevent Them

It arrives without warning. The calf locks, the foot points itself, and you are suddenly upright in the dark holding your leg and waiting for it to let go. Thirty seconds, sometimes two minutes. Then it releases, and the muscle stays sore into the next day.
This is extremely common, particularly after fifty and particularly at night. It is also one of the areas where the confident advice you get is furthest ahead of what is actually known.
So let me be straight about which parts are understood, which are guesswork, and what is worth your time.
What a cramp actually is
A cramp is a sudden, involuntary, sustained contraction of a muscle that will not release on command. The calf and the small muscles of the foot are the usual sites.
One proposed explanation is that it starts in the nerve rather than the muscle. Motor nerves supplying a muscle can begin firing repetitively on their own, and the muscle simply obeys. What makes them more excitable is where the certainty runs out, muscle held in a shortened position, a day of unusual activity, and age-related changes in the nerve endings themselves are all in the frame.
The night-time part fits that picture. Lying down with the foot naturally pointed holds the calf in its shortest position for hours, which is a known trigger. It is also why the cramp so often breaks the moment you stand up or pull your toes toward you.
A systematic review of how nocturnal leg cramps are even defined found the criteria themselves vary between studies [1], which tells you something about the state of the field. This is a common complaint that has been studied less rigorously than it deserves.
About magnesium: the honest answer
This is the first thing everyone is told, and it is the question underneath most searches on this subject, so it deserves a straight answer rather than a hedge.

A Cochrane systematic review examined magnesium for skeletal muscle cramps, including the ordinary night-time kind in older adults. Its conclusion for that group was that magnesium is unlikely to provide clinically meaningful cramp reduction [2].
That is not the same as saying magnesium is useless in life. It is a genuine nutrient with genuine roles, and a real deficiency is a real thing. It is saying that for ordinary nocturnal cramps in someone who is not deficient, the supplement is not the answer people have been sold, and if a fair trial has made no difference, the honest reading is that it is not helping you, rather than that you need a different brand.
The same applies to tonic water. Quinine does reduce cramps and is also associated with serious side effects, which is why it is not something to reach for on your own. It is not a home remedy worth pursuing.
What tends to actually help
The useful interventions are mechanical, not nutritional.
Stretch the calf before bed. If your ankles also puff in warm weather, swollen ankles in the heat is a different mechanism again. It is the same calf that pumps blood back up when you break up long sitting. Standing an arm's length from a wall, hands on the wall, one leg back with the heel down, hold for about thirty seconds each side, a few times. The evidence here is modest rather than overwhelming, but it is more supported than the supplements, it costs nothing, and it targets the actual mechanism.
Change how your foot sits at night. Keep the bedding loose over your feet rather than tucked tight, which holds the foot pointed all night. Some people do better sleeping with feet slightly hanging off the end, or lying face down with feet over the edge.
Break the cramp by lengthening the muscle. Straighten the leg and pull your toes firmly toward your shin. Standing and putting weight through the leg does the same thing. Massaging afterwards helps the soreness rather than the cramp.
Keep fluid up, particularly in hot weather. The evidence for dehydration as a cause is mixed, but it costs nothing and is more likely to help than a capsule.
Look at the day, not just the night. A long day standing still, an unusually hard walk, or a new pair of shoes will show up at two in the morning.
Ask about your medicines. Diuretics, some blood pressure medicines, statins and some asthma medicines are associated with cramps. This is worth raising with your doctor or pharmacist, and it is more likely to be the answer than a mineral. Never stop anything yourself.
The circulation question, answered properly
People often assume a night cramp means poor circulation, and it is worth separating two different things, because one of them matters.
Cold hands and feet are a separate story. Ordinary nocturnal cramps are a nerve-and-muscle event, not a blood-supply event. They happen at rest, they release with stretching, and they are not a sign that your legs are short of blood.
Cramping pain in the calf that comes on when you walk and stops when you stand still is different. That pattern is about blood supply during effort, it has a name, and it belongs with a doctor rather than a stretching routine. If your leg pain is brought on by walking a predictable distance and relieved by rest, do not file it under night cramps.
When to get it looked at
Talk to your doctor about cramps that come with swelling, redness or warmth in one calf, cramps with numbness, weakness or pins and needles, cramps that are frequent, severe or getting worse, cramps that started after a new medication, cramps in someone with diabetes, kidney disease, thyroid disease or liver disease, and any calf pain that is brought on by walking and relieved by rest.

A single calf that is swollen, warm and painful is not a cramp and needs to be seen the same day.
The realistic version
Ordinary night cramps are common, usually harmless, and genuinely annoying. The stretching and the bedding changes are worth doing because they address the mechanism and cost nothing. The supplements are worth less than you have been told, and the review evidence says so plainly.
If they are frequent, one-sided, or brought on by walking, that is not the version this article is about.
References
[1] Hallegraeff, J., de Greef, M., Krijnen, W., & van der Schans, C. (2017). Criteria in diagnosing nocturnal leg cramps: a systematic review. BMC Family Practice, 18(1), 29. https://pubmed.ncbi.nlm.nih.gov/28241802/
[2] Garrison, S. R., Korownyk, C. S., Kolber, M. R., Allan, G. M., Musini, V. M., & Sekhon, R. K. (2020). Magnesium for skeletal muscle cramps. Cochrane Database of Systematic Reviews, 9(9), CD009402. https://pubmed.ncbi.nlm.nih.gov/32956536/
Educational content only, not medical advice. Dr. LongHeart is a European-trained physician and is not licensed to practice medicine in the United States. This article is for general information and does not diagnose, treat, or replace care from a professional. Always consult your own doctor about your health, medications, and any changes to your routine. Reviewed for educational accuracy by Dr. LongHeart.


