Leg Cramps at Night: Causes, Missing Minerals and Relief

Leg Cramps at Night: Causes, Missing Minerals and Relief – Dr. Matt Gianforte

By | Functional Medicine Clinician

A calf muscle that suddenly locks into a hard, painful knot can jolt anyone out of deep sleep. The worst of it may pass in a few minutes, but the soreness can last into the morning. When people look up leg cramps at night, causes such as missing minerals top the list, and magnesium gets most of the attention. The research tells a more mixed story, so knowing what really sets these cramps off is the first step toward relief.

Night leg cramps, also called nocturnal leg cramps, are sudden and painful tightenings of a muscle, most often the calf, that strike during rest or sleep. Research points mainly to tired muscles and overactive nerves rather than low minerals, though some drugs and health problems raise the odds. Nightly stretching has the best trial support so far, while magnesium fits best for people with a clear reason to run low.

  • Up to 60 percent of adults report having had leg cramps at night, and they become more common with age.
  • Muscle fatigue, overactive nerve signals and the pointed-toe position of the foot during sleep appear to drive most cramps.
  • Some prescriptions, including certain diuretics and inhalers, are linked to cramps that begin after the drug is started.
  • The current Cochrane review found magnesium unlikely to help typical cramps in older adults, and other trials are mixed.
  • Missing minerals matter most for people with gut disease or long-term use of diuretics or acid reducers.

Why Leg Cramps at Night Are So Often Misread

The gap between what people expect and what research shows starts with how common these cramps are. Up to 60 percent of adults report having had nocturnal leg cramps, which are slightly more common in women and become more frequent with age (Allen and Kirby, 2012). In a general population survey, 37% of adults had cramps at rest, and most of them noticed the cramps at night (Naylor and Young, 1994).

The same survey found that a typical episode lasted about 9 minutes, and 40% of people with cramps had them more than three times a week. Reviewers note that night cramps can cause severe insomnia (Allen and Kirby, 2012). Even so, only about a third of the people with cramps in that survey had told a doctor.

The word "cramp" also gets used for several different leg problems, which adds to the confusion. Restless legs syndrome brings an irresistible urge to move the legs rather than a hard, painful knot. Claudication is an aching or cramping pain that comes on with exercise and eases with rest (Allen and Kirby, 2012). The table below sorts the most common look-alikes.

Pattern Common clues What to ask a clinician about
Nocturnal leg cramps A sudden, hard and painful knot, usually in the calf, during rest or sleep A medication review and a stretching plan.
Restless legs syndrome An urge to move or shake the legs rather than a locked muscle A sleep and symptom history.
Claudication Aching or cramping that starts with walking and eases with rest A check of blood flow to the legs.
Deep vein clot Swelling, warmth, redness or tenderness in the affected leg Prompt medical care.
Medication-related cramps Cramps that begin after a new prescription is started Whether the drug or the dose could be adjusted.

Because the history usually separates these patterns, routine blood tests are not helpful for diagnosing ordinary night cramps (Allen and Kirby, 2012). That leaves the research on what actually reduces cramps as the best guide, and most of it has focused on one mineral.

What the Research Says About Magnesium for Leg Cramps

Magnesium for leg cramps is the most popular home remedy, so it has also been studied the most. The Cochrane review, last updated in 2020, pooled 11 trials with 735 people (Garrison et al., 2020). For typical cramps in older adults, magnesium made only small changes in how often cramps struck, and those changes were not significant. The authors concluded that magnesium is unlikely to give older adults a meaningful drop in cramps.

The picture is less clear for other groups, and the review called the evidence for cramps in pregnancy conflicting. It found no trials at all for cramps tied to exercise. Magnesium pills mostly caused stomach and bowel side effects such as diarrhea, and minor side effects were more common than with placebo.

Newer trials have kept the debate open. In a double-blind trial, 226 mg of magnesium oxide monohydrate at bedtime for 60 days led to a slightly larger drop in cramp episodes than placebo, 3.4 versus 2.6 (Barna et al., 2021). In a Finnish trial of 121 adults aged 50 to 85, however, magnesium did no better than placebo pills, while knee-high compression stockings reduced weekly cramps (Kuusipalo et al., 2026).

Population data add one more twist. In a Swiss cohort, people who already took magnesium went on to report more night cramps, not fewer (Stadie et al., 2026). Data like these cannot prove cause and effect, since people with cramps may simply be more likely to reach for magnesium.

Infographic comparing the evidence for magnesium with nightly stretching and compression stockings for leg cramps at night

Stretching has more direct support. In a randomized trial, 80 adults over 55 stretched their calves and hamstrings each night just before sleep for six weeks (Hallegraeff et al., 2012). Their cramps fell by about 1.2 per night more than in a group that did not stretch, and the cramps that remained hurt less.

Prescription options carry real tradeoffs. Quinine likely works, but the American Academy of Neurology advises against routine use because it can be toxic, following a 2006 FDA warning against using it for cramps (Katzberg et al., 2010). The same review rated vitamin B complex and the drug diltiazem as possibly effective, based on limited studies.

Taken together, the research supports nightly stretching as the first step, while magnesium makes the most sense for people with a real reason to run low rather than as an answer for every cramp.

Root Causes of Leg Cramps at Night

If magnesium is not the whole answer, the root causes must lie somewhere else. Researchers believe tired muscles and nerve problems drive most night cramps, rather than low electrolytes (Allen and Kirby, 2012). The cramp seems to start in the nerves that run the muscle, which fire fast signals that the muscle cannot ignore.

Sleep position adds to the problem. In bed, the foot rests with the toes pointed down, so the calf stays in its shortest position for hours. A tired, short muscle that gets a burst of nerve signals is ready to lock up, which may explain why stretching before bed helps.

Hub infographic of leg cramps at night causes: tired muscles, overactive nerve signals, pointed-toe sleep position, medications, low magnesium and health conditions

Medications are one of the most overlooked causes. Data on 4.2 million people in British Columbia showed that adults 50 and older were more likely to start cramp treatment in the year after starting certain drugs (Garrison et al., 2012). The strongest links were with inhalers called long-acting beta-agonists (LABAs) and with potassium-sparing or thiazide-like diuretics, which are types of water pills. Links to statins and loop diuretics were small, and the study found that 60.3% of people treated for cramps had used at least one of these drugs.

Other drugs have been tied to cramps too, including iron sucrose given by IV, conjugated estrogens, raloxifene, naproxen and teriparatide (Allen and Kirby, 2012). Night cramps are also linked with vascular disease, a narrow lower spinal canal (lumbar stenosis), cirrhosis, dialysis and pregnancy.

Missing minerals still matter for some people, which is where the popular advice has a point. Low magnesium can cause muscle cramps, but deficiency with symptoms is uncommon in healthy people because the kidneys hold on to magnesium when intake runs low (NIH Office of Dietary Supplements). The risk climbs with gut diseases, type 2 diabetes, alcohol dependence and older age.

Some drugs widen that gap, because long-term use of loop and thiazide diuretics raises magnesium loss in urine. Acid-reducing drugs called proton pump inhibitors (PPIs) can lower blood magnesium when taken for more than a year. Dehydration and low sodium, potassium or calcium can also make a muscle more likely to spasm (MedlinePlus).

Low minerals are one possible cause of night cramps, not the usual one, which is why a medication history and targeted testing matter more than guessing.

A Functional Medicine Protocol for Nighttime Leg Cramps

Because several causes can stack up in one person, a functional medicine plan works through them in order. Practitioners usually start with the pattern and the drug list, rule out look-alikes, and only then decide whether minerals belong in the plan.

  1. Keep a cramp diary that notes the time, the muscle, how long each cramp lasts and what happened that day.
  2. Bring a full list of drugs and supplements, with start dates, to a clinician, since cramps can begin in the year after a new drug.
  3. Rule out look-alikes such as restless legs, claudication and a blood clot, which each need different care.
  4. Order labs with a purpose, such as magnesium and potassium checks for people on diuretics or long-term PPIs, or with gut disease.
  5. Stretch the calves and hamstrings every night right before bed, since this step has the most direct trial support.
  6. Fill real mineral gaps with food first and supplements second, keeping supplemental magnesium at or under 350 mg a day.

Lab results need care, because blood magnesium does not show how much is stored inside cells and bone (NIH Office of Dietary Supplements). If cramps keep coming despite stretching, a clinician may also suggest a trial of knee-high compression stockings (Kuusipalo et al., 2026).

Steps infographic of a functional medicine protocol for nighttime leg cramps: cramp diary, medication review, rule out look-alikes, nightly stretching, fill real mineral gaps

Supplement Support: The Best Magnesium for Leg Cramps and Electrolytes

Once the diary and drug review point to low intake or extra losses, supplements can fill a real gap. No form of magnesium has been proven best for cramps. Even so, the aspartate, citrate, lactate and chloride forms tend to be absorbed better than magnesium oxide and sulfate (NIH Office of Dietary Supplements). Labels list elemental magnesium, and the total from all supplements should stay at or under 350 mg a day, the upper limit.

Standard Process Magnesium Lactate uses one of those well-absorbed forms. Its label suggests two tablets a day, which give 200 mg of magnesium. The product names energy, electrolyte balance and muscle health among the roles of magnesium, and this dose leaves room under the upper limit. Shop Magnesium Lactate →

Magnesium glycinate is magnesium bound to the amino acid glycine. Trace Minerals describes this form as well absorbed and well tolerated, and notes that glycine has calming effects of its own. Its powder mixes into water once a day, and the label lists the elemental magnesium in each serving. This guide to liquid magnesium glycinate covers the form in more detail. Shop Magnesium Glycinate Powder →

Electrolytes fit people who lose minerals through long activity and heavy sweat, since fluids and minerals during exercise may ease muscle spasms (MedlinePlus). Endurance Products Electrolyte SR provides sodium, potassium, chloride and magnesium in a tablet that releases them slowly over 6 to 8 hours. Its label directs 1 to 2 tablets with water before, during or after activity. This overview of electrolytes for intermittent fasting explains how these minerals work together. Shop Electrolyte SR →

Electrolyte SR contains potassium, so people with kidney disease, or who take ACE inhibitors, ARBs or potassium-sparing diuretics, should ask a clinician first. These raise the risk of high potassium (NIH Office of Dietary Supplements, Potassium). All three products also contain magnesium, so it makes sense to pick one main source rather than stacking them. Explore practitioner-grade supplement protocols at drmattgianforte.com.

Lifestyle Integration for Fewer Night Cramps

Supplements work best on top of daily habits, and the most useful habit takes only a few minutes before bed. Simple calf and hamstring stretches, done right before sleep, match the routine used in the stretching trial (Hallegraeff et al., 2012). Mild exercise, such as a few minutes on a stationary bike or treadmill before bedtime, has also been suggested by reviewers (Allen and Kirby, 2012).

When a cramp strikes, a firm stretch of the muscle, pulling the toes back toward the shin, is thought to relieve it. Deep tissue massage is a safe follow-up, and both steps are easy to do in the middle of the night before reaching for anything else.

Food supplies magnesium without the stomach upset that high-dose pills can cause. Green leafy vegetables, legumes, nuts, seeds and whole grains are all good sources (NIH Office of Dietary Supplements), and potassium-rich foods such as oranges and bananas help cover another muscle mineral (MedlinePlus). This guide to nutrient deficiency symptoms covers other signs that minerals may be running low.

Sleep itself deserves attention, since cramps and poor sleep feed each other. This overview of the best magnesium supplement for sleep covers how magnesium fits an evening routine. Most people can try these steps safely, but some patterns call for a clinician first.

When to See a Clinician About Leg Cramps at Night

Several common drugs are linked to cramps, yet that is not a reason to stop them. Don't stop or change prescribed medication without talking to your clinician. Magnesium can also bind some antibiotics and cut the absorption of bone drugs called bisphosphonates. Doses should be spaced at least 2 hours apart, and longer for some antibiotics (NIH Office of Dietary Supplements).

Checklist infographic of when to see a clinician about leg cramps at night, including a swollen warm leg, chest pain or trouble breathing, and cramps after a new medication

Some symptoms need a medical visit rather than a stretching routine, including these warning signs and situations:

  • Pain, swelling, warmth, tenderness or redness in a leg, which are common signs of a deep vein clot that can break loose and travel to the lungs (MedlinePlus, DVT).
  • Shortness of breath, chest pain that gets worse with a deep breath or cough, a fast heartbeat or fainting, which can signal a clot in the lungs that needs treatment right away (MedlinePlus, PE).
  • Cramps that are severe, keep coming back, last a long time or do not ease with simple stretching (MedlinePlus).
  • Leg pain that comes on with walking and eases with rest, which can point to claudication and poor blood flow.
  • Cramps that began soon after a new prescription was started.
  • Pregnancy, kidney disease or several daily medications before starting magnesium or electrolyte supplements.

Checking these first keeps the plan safe and makes sure a more serious problem is not hiding behind what looks like an ordinary cramp.

Conclusion: Making Sense of Leg Cramps at Night

Leg cramps at night are common and painful, and they are often blamed on one missing mineral, yet the research tells a wider story. The usual causes are tired muscles, overactive nerves, the pointed-toe sleep position, some drugs and some health problems. Low magnesium matters most for people with a real reason to lose it. A cramp diary, a drug review, nightly stretching and targeted minerals give most people a safe place to start.

Practitioner-grade protocols for leg cramps at night and the sleep they interrupt are available at drmattgianforte.com, formulated with the same clinical-quality supplements used in functional medicine practice. Explore the Protocol →

FAQ

What causes leg cramps at night?

Most leg cramps at night appear to come from muscle fatigue and overactive nerve signals, made worse by the pointed-toe position of the foot during sleep. Certain medications, such as some diuretics and inhaled long-acting beta-agonists, along with conditions like vascular disease and pregnancy, can raise the risk.

Does magnesium actually work for leg cramps?

The Cochrane review found magnesium unlikely to help typical leg cramps in older adults, although one later trial found a modest benefit. Magnesium makes the most sense for people with low intake or extra losses, such as long-term diuretic or PPI use.

What is the best magnesium for leg cramps?

No form of magnesium has been proven best for leg cramps. The citrate, lactate, aspartate and chloride forms tend to be absorbed better than oxide, and glycinate is a chelated form that its makers describe as well tolerated. Total supplemental magnesium should stay at or under 350 mg a day.

Can medications cause leg cramps at night?

Yes, cramp treatment becomes more likely after people start certain diuretics or inhaled long-acting beta-agonists, and statins show a smaller link. Anyone who suspects a medication should talk with their clinician rather than stopping it on their own.

How do you stop a leg cramp in the middle of the night?

A firm stretch of the cramping muscle, such as pulling the toes back toward the shin, is thought to relieve a cramp, and deep tissue massage can help afterward. Stretching the calves and hamstrings every night before bed may lower how often cramps return.

When are leg cramps a sign of something serious?

Swelling, warmth, redness or tenderness in a leg can signal a blood clot and needs prompt medical care. Cramps that are severe, keep coming back or come with walking and ease with rest should also be checked by a clinician.

References

  • Allen RE, Kirby KA. Nocturnal leg cramps. Am Fam Physician. 2012. PubMed 22963024; full text
  • Naylor JR, Young JB. A general population survey of rest cramps. Age Ageing. 1994. PubMed 7825490
  • Garrison SR, Korownyk CS, Kolber MR, Allan GM, Musini VM, Sekhon RK, Dugré N. Magnesium for skeletal muscle cramps. Cochrane Database Syst Rev. 2020. PubMed 32956536
  • Barna O, et al. A randomized, double-blind, placebo-controlled, multicenter study assessing the efficacy of magnesium oxide monohydrate in the treatment of nocturnal leg cramps. Nutr J. 2021. PubMed 34719399
  • Kuusipalo A, Laitila J, et al. Secondary prevention of leg cramps using compression stockings or magnesium supplements: a three-arm randomized clinical trial. Trials. 2026. PubMed 41680812
  • Stadie N, Heinzer R, Marques-Vidal P. Magnesium supplements, sleep quality, and nocturnal leg cramps: a combination of cross-sectional and prospective studies. Eur J Nutr. 2026. PubMed 41697399
  • Hallegraeff JM, van der Schans CP, de Ruiter R, de Greef MH. Stretching before sleep reduces the frequency and severity of nocturnal leg cramps in older adults: a randomised trial. J Physiother. 2012. PubMed 22341378
  • Katzberg HD, Khan AH, So YT. Assessment: symptomatic treatment for muscle cramps (an evidence-based review). Neurology. 2010. PubMed 20177124
  • Garrison SR, Dormuth CR, Morrow RL, Carney GA, Khan KM. Nocturnal leg cramps and prescription use that precedes them: a sequence symmetry analysis. Arch Intern Med. 2012. PubMed 22157068
  • NIH Office of Dietary Supplements. Magnesium: Fact Sheet for Health Professionals. ods.od.nih.gov
  • NIH Office of Dietary Supplements. Potassium: Fact Sheet for Health Professionals. ods.od.nih.gov
  • MedlinePlus. Muscle cramps. medlineplus.gov
  • MedlinePlus. Deep Vein Thrombosis. medlineplus.gov
  • MedlinePlus. Pulmonary Embolism. medlineplus.gov

This article is for education and isn't medical advice. Readers should talk with their own healthcare provider about their situation.

These statements have not been evaluated by the Food and Drug Administration. Products and information on this site are not intended to diagnose, treat, cure, or prevent any disease. Consult your healthcare provider before starting any supplement.

Back to Health Articles