What causes leg cramps at night? The common reasons for muscle cramps, and the tests that check the rest

Most night-time leg cramps come with age, tired muscles, pregnancy or a medicine rather than low minerals, and the few tests that matter are for kidney, thyroid, blood sugar and muscle damage.

Reviewed by LifeFrom’s medical AIPublished November 11, 2026 · 12 min read
Ask AI about this pageChatGPTClaudePerplexity
The distinctions
  1. 01
    Most night cramps aren't caused by low potassium or dehydration

    Bananas and water are the folk remedy, but the American Family Physician review found night-time and exercise cramps haven't been linked with dehydration or with low potassium, sodium or magnesium. They are mostly put down to muscle fatigue and nerve misfiring, and become more common with age. Mineral levels matter mainly when something else, such as vomiting, diarrhea, a diuretic or kidney disease, has pushed them out of range.

  2. 02
    A cramp at rest is not the same as calf pain when walking

    A cramp is a sudden hard knot, usually at night, that eases when you stretch it. Aching or cramping in the calf that comes on every time you walk a certain distance and eases when you stop is claudication, the main sign of narrowed leg arteries, and needs a doctor.

A muscle cramp is a sudden, painful tightening of a muscle, most often the calf, that you can feel as a hard knot; it usually lasts from a few seconds to 10 minutes and can leave the muscle sore for a day. 3 Most night-time leg cramps have no single cause: they become more common with age and are probably driven by tired muscles and nerves firing too much, not by low minerals. 1 Hard exercise, especially in heat, late pregnancy and medicines such as statins and diuretics are the common triggers, and artery disease in the legs, nerve damage, kidney failure, cirrhosis and an underactive thyroid are the medical causes worth checking. 123

When to get help now

Ordinary cramps are painful but harmless. These signs are the exceptions.

Call 911 or your local emergency number
  • Severe muscle pain or weakness with dark, red or cola-colored urine, or much less urine, especially after hard exercise, heat or a new medicine 6
  • A swollen leg with sudden shortness of breath, chest pain or coughing up blood 11
  • Cramps or stiffness with confusion, a very high temperature or collapse in the heat
See a doctor soon, the same day if you can
  • One leg that is swollen, warm, red or painful, which can be a blood clot 11
  • Cramps with numbness or swelling in the legs 3
  • Cramps that last longer than 10 minutes, or keep disturbing your sleep 3
  • Calf, thigh or buttock pain that comes on with walking and goes away with rest 7
  • New muscle weakness, or aching muscles since starting a statin 1

LifeFrom can't examine you or assess a symptom. If something feels seriously wrong, trust that and get care rather than waiting on a test.

What a cramp is, and what is normal

Cramps are common. The 2012 American Family Physician review puts night-time leg cramps at 50 to 60% of adults and about 7% of children, notes they are slightly more common in women and rise with age, and says up to 20% of people who get them have daily cramps bad enough to see a doctor. 1 The NHS describes a cramp as a leg muscle that "tightens and causes a sudden pain that can make it hard to move," and notes the muscle may feel sore for up to 24 hours after. 3

50 to 60%of adults report night-time leg crampsUp to 20% of them have daily symptoms. Source: American Family Physician, 2012. 1

The distinction most people get wrong is the cause. The common belief is that cramps mean you're short of water, potassium or magnesium. The American Family Physician review states the opposite for the usual cramps: "Neither exercise-related cramps nor nocturnal cramps have been associated with hypovolemia (caused by dehydration) or disturbances of electrolytes such as potassium, sodium, and magnesium." 1 It points to muscle fatigue and nerve dysfunction instead, and one theory is that lying with the foot pointed leaves the calf already shortened, so a stray nerve signal tips it into a cramp. 1 MedlinePlus still lists dehydration and low sodium, potassium or calcium as things that make cramps during exercise more likely, so minerals matter when something has pushed them out of range. 2

Night cramp or claudication? Which pattern is yours

Leg cramp✓ Usually harmless; stretch it
Sudden knot, often at night
When it comesAt rest or in bed, often at night 13
What it feels likeSudden, intense pain with a visibly tight muscle 1
What eases itStretching or massaging the muscle, standing on the leg 3
What checks itYour history; tests are rarely needed 1
ClaudicationSee a doctor: a sign of artery disease
Pain that walking brings on
When it comesWhen walking or climbing stairs 7
What it feels likeAching, heaviness or cramping, often in the calf 7
What eases itRest 7
What checks itAnkle-brachial index (blood pressure in ankle vs arm) 1
Patterns from the American Family Physician review (2012), the NHS and the NHLBI. Claudication is the most common symptom of peripheral artery disease.

Two other look-alikes are worth separating. Restless legs is an urge to move the legs with creeping or tingling feelings, uncomfortable but not painful and with no tight muscle, and it eases while you move. 1 Nerve damage brings numbness, tingling and electric-feeling pain with cramps only as a side effect; see tingling hands and feet. 1

What can cause it, most likely first

Ranked from most to least likely in adults in general. The order shifts with age, sex and history: idiopathic night cramps dominate in older adults, exercise cramps in active people, pregnancy for pregnant women, and medicines for anyone who started one recently.

  1. 01
    Age and idiopathic night crampsEverydaycommon

    "Most cases of leg cramps are idiopathic," meaning no cause is found, and they become more common with age. 1 The NHS lists ageing first among the causes. 3 These cramps are probably driven by nerves firing too much and by tired muscles rather than a deficiency, which is why they rarely need blood tests. 1

  2. 02
    Hard exercise, tired muscles and heatEverydaycommon

    Muscle fatigue is thought to be a primary cause, and in endurance athletes cramps go with exercising harder than usual. 1 The NHS says straining muscles during exercise can cause cramps, worse in hot or humid weather. 3 A change in training intensity can bring them on even in fit people. 1

  3. 03
    Not drinking enough, or heavy fluid lossEverydaycommon

    MedlinePlus and the NHS list dehydration as a cause, and MedlinePlus calls not getting enough fluids the most common cause of cramps during sport. 23 The American Family Physician review found no link between dehydration and the usual night or exercise cramps, so the evidence is mixed. 1 Vomiting, diarrhea and heavy sweating matter more, because they can also drain minerals. 2

  4. 04
    MedicinesEverydaycommon

    The NHS names statins (for cholesterol) and diuretics (water pills for blood pressure) as examples. 3 The American Family Physician review lists the medicines most clearly linked with leg cramps as intravenous iron sucrose, conjugated estrogens, raloxifene, naproxen and teriparatide, plus some inhaled asthma medicines such as levalbuterol and albuterol with ipratropium. 1 Statins can also cause muscle aches and, rarely, muscle damage. 1 Don't stop a medicine on your own; ask the prescriber.

    Creatine kinase (CK)
    A high CK points to muscle damage, for example myositis linked with a statin, and a very high CK with dark urine points to rhabdomyolysis, an emergency. 16
  5. 05
    PregnancyEverydaycommon

    Leg cramps are common in pregnancy, usually in the later stage. 3 The American Family Physician review notes it's hard to tell whether pregnancy itself or the vein changes that come with it are the cause. 1 Cochrane found trials of magnesium in pregnancy conflicting and too weak to rely on. 4

  6. 06
    Low potassium, calcium, magnesium or sodiumMedicalless common

    Low levels of sodium, potassium or calcium make muscle spasms more likely, and a clinician may check calcium, potassium and magnesium when cramps are frequent. 2 In a study of outpatient veterans, 63% of those with low potassium reported leg cramps. 1 Low levels usually have a reason, such as diuretics, vomiting, diarrhea or kidney disease, which is what the clinician looks for. See electrolytes explained.

    Potassium
    A low potassium (hypokalemia) can be linked with cramps and weakness; common reasons are diuretics, vomiting and diarrhea. 12
    Calcium
    A low calcium can make muscle spasms more likely. 2 Total calcium is read alongside albumin, because low albumin makes it look low; see the corrected calcium calculator.
    Magnesium
    A low magnesium is one of the mineral results a clinician checks when cramps are frequent; a normal result makes a magnesium cause less likely. 2
    Sodium
    A low sodium can make muscle spasms during exercise more likely, and heavy sweating is one way it drops. 2
  7. 07
    Narrowed leg arteries (peripheral artery disease)Medicalless common

    Pain, aching, heaviness or cramping in the legs that comes with walking or stairs and goes away with rest is claudication, "the most common PAD symptom." 7 In outpatient veterans, 75% of those with peripheral vascular disease reported leg cramps. 1 No blood test diagnoses PAD; an ankle-brachial index does, though cholesterol and blood sugar tests check the risk factors. 1 See high cholesterol.

  8. 08
    Nerve damage from diabetes, low B12 or alcoholMedicalless common

    Peripheral neuropathy, nerve damage in the feet and legs, is linked with leg cramps and mostly brings numbness, tingling and electric-feeling pain. 1 Diabetes, low vitamin B12, heavy alcohol use and HIV are the usual causes, and high blood sugar damages the nerves and the small vessels that feed them. 110 Lumbar spinal stenosis, a narrowing in the lower back, is linked with cramps too. 1

    Can be linked with Vitamin B12 deficiency

    HbA1c
    A high HbA1c points to blood sugar that has run high over recent months, the main cause of diabetic nerve damage. 10 See prediabetes.
    Vitamin B12
    A low B12 can be linked with nerve damage that brings numbness, tingling and cramps; a borderline result is often followed up with more tests. 1
  9. 09
    Kidney failure and dialysisMedicalless common

    The NIDDK lists muscle cramps, weakness or numbness among the symptoms as kidney function falls toward kidney failure. 9 The American Family Physician review links cramps with hemodialysis but not with earlier chronic kidney disease, and ties dialysis cramps to high phosphate. 1 See kidney function explained.

    Can be linked with Chronic kidney disease

    eGFR
    A low eGFR (estimated glomerular filtration rate) points to reduced kidney filtering; cramps are most linked with kidney failure and dialysis. 19
    Creatinine
    A high creatinine points to the kidneys clearing waste more slowly; eGFR is calculated from it. 9
  10. 10
    Underactive thyroid or liver diseaseMedicalrare

    MedlinePlus lists hypothyroidism (an underactive thyroid) as a trigger for cramps, and the NIDDK lists joint and muscle pain, fatigue and feeling cold among its symptoms. 28 About 60% of people with cirrhosis reportedly have leg cramps, mostly older people with advanced disease, and the NHS lists liver disease from alcohol. 13 See always cold for the other thyroid signs.

    Can be linked with Hypothyroidism

    TSH
    A high TSH (thyroid stimulating hormone) points to an underactive thyroid; it is the first thyroid test. See how to read your thyroid panel.

These are things a symptom like this can be linked with, not a diagnosis. Several can sit together, and a clinician who knows your history puts them in order for you.

Why leg cramps strike at night

Leg cramps are "usually nocturnal," and the reasons are partly mechanical. 1 Lying in bed, the foot rests pointed down and the calf muscle is already at its shortest, so researchers think an uninhibited nerve signal tips it into a cramp. 1 Muscles tired from the day add to it, and the review notes that cramps can bring on real insomnia. 1 If cramps are only part of what keeps you up, see can't sleep.

Do you need blood tests for leg cramps?

For ordinary night cramps, usually not. The American Family Physician review's first key recommendation is that "routine laboratory tests, such as electrolyte levels, are unnecessary," and that the history should be used to diagnose them. 1 Tests earn their place when cramps are frequent, severe or new, come with other symptoms, or start with a new medicine. Then MedlinePlus lists calcium, potassium and magnesium, kidney function and thyroid function as the checks. 2 A clinician will also ask about vomiting, diarrhea, heavy sweating, alcohol and exercise. 2

PatternWhat it can point toWhat checks it
Night calf cramps, older adult, otherwise wellIdiopathic cramps 1History; usually no tests 1
Cramps during or right after hard exerciseMuscle fatigue, heat, fluid and salt loss 12History; sodium if heavy sweating 2
Cramps after starting a medicineMedicine side effect 13Medicine review; CK if muscles ache 1
Cramps with vomiting, diarrhea or a diureticLow potassium, magnesium or sodium 2Electrolyte panel 2
Calf pain on walking, eased by restPeripheral artery disease 7Ankle-brachial index 1
Cramps with numbness or tinglingNerve damage 1HbA1c, vitamin B12 110
Cramps with fatigue, feeling cold, weight gainUnderactive thyroid 8TSH 2
Muscle pain with dark urineRhabdomyolysis (emergency) 6CK, kidney tests, urine tests 6

The panel that checks these

If a clinician tests, potassium, calcium and magnesium come first with eGFR and creatinine for the kidneys, then TSH; HbA1c and B12 follow when there is numbness or tingling, and CK when muscles ache after a new medicine or hard exercise. None of these needs fasting. Mention hard exercise in the days before, since severe exertion can raise CK on its own. 6

  1. Creatine kinase (CK)Medicines
  2. PotassiumLow potassium, calcium, magnesium or sodium
  3. CalciumLow potassium, calcium, magnesium or sodium
  4. MagnesiumLow potassium, calcium, magnesium or sodium
  5. SodiumLow potassium, calcium, magnesium or sodium
  6. HbA1cNerve damage from diabetes, low B12 or alcohol
  7. Vitamin B12Nerve damage from diabetes, low B12 or alcohol
  8. eGFRKidney failure and dialysis
  9. CreatinineKidney failure and dialysis
  10. TSHUnderactive thyroid or liver disease
Already have results?Add them to LifeFrom and it reads these markers side by side, against each other and over time, in plain language. Free, on the web or in the app.

LifeFrom doesn't sell blood tests. It reads results from any lab and helps you prepare for your own doctor; it doesn't diagnose.

Getting a useful test

  • Note when cramps happen, which muscle, how long they last and what stops them; the history is what clinicians rely on. 1
  • List every medicine with its start date, including statins, diuretics, asthma inhalers, raloxifene and hormone treatments. 13
  • Mention vomiting, diarrhea, heavy sweating or heavy drinking. 2
  • Mention numbness, swelling, or calf pain that comes on with walking. 37
  • One result is a snapshot; see why trends beat single readings.

Quinine and magnesium: what the evidence says

Quinine was once the standard pill for night cramps. In the US the FDA's boxed warning on quinine sulfate says that using it for night-time leg cramps "may result in serious and life-threatening hematologic reactions," meaning dangerous blood problems such as a very low platelet count, and that the risk "outweighs any potential benefit." 5 The American Family Physician review agrees: "Quinine should not be used to treat nocturnal leg cramps." 1 The NHS still lists quinine as something a UK doctor may weigh when stretching hasn't helped, with a discussion of risks. 3

It is unlikely that magnesium supplementation provides clinically meaningful cramp prophylaxis to older adults experiencing skeletal muscle cramps.

Cochrane review, Garrison et al., 2020 4

Magnesium is the most marketed supplement for cramps. The 2020 Cochrane review pooled five trials in 271 older adults and found it unlikely to help, while five trials in pregnancy gave conflicting results and none tested people who cramp while exercising. 4 Mild stomach upsets such as diarrhea were the main side effect. 4 Magnesium matters when a blood test shows it is low; for ordinary cramps the evidence doesn't support it.

What may help

Stretching is the one everyday step with support for night cramps, and the rest are sensible ways to cut the triggers.

Start with the everyday things
  • Do a calf stretch: face a wall, lean in with your feet flat until the calves stretch, hold a few seconds and repeat for 5 minutes, 3 times a day, the last just before bed. 3
  • During a cramp, stretch and massage the muscle, or stand and put weight on the leg. 3
  • Exercise within your ability and build up gradually, especially in hot or humid weather. 23
  • Drink enough fluids when exercising or in heat; MedlinePlus notes that after heavy sweating water alone may not be enough, since minerals are lost too. If you have heart or kidney disease or watch your salt, check with your clinician first. 2
  • Ask the prescriber about any medicine that started around when the cramps did. 3

No supplement is listed. A Cochrane review found magnesium unlikely to help older adults with ordinary cramps, and quinine is not a supplement and carries an FDA boxed warning for this use. 45 Supplements support general wellness. They don't treat the causes above, and if a test finds one, treating that comes first. If you take medicines, are pregnant or have a health condition, check with your clinician before starting anything.

Questions to ask your clinician

  • Could any of my medicines be causing the cramps?
  • Do my cramps need any tests, and if so, which: electrolytes, kidney, thyroid, HbA1c, B12 or CK?
  • Is my calf pain on walking a sign of artery disease, and should I have an ankle-brachial index?
  • Could nerve damage or my back be part of this?
  • Which signs would mean I should come back sooner?

This page is general education, not medical advice or a diagnosis. Cramps often have more than one contributor, and the clinician who knows your history and examines you is the one to read your results and decide what matters.

Free in LifeFromAdd the lab results you already have, and LifeFrom reads each marker next to the others it moves with, in plain language, with the sources it used. Free, on the web or in the app.
Citations
  1. Allen RE, Kirby KA. Nocturnal leg cramps. Am Fam Physician. 2012;86(4):350-355.
  2. MedlinePlus Medical Encyclopedia. Muscle cramps. US National Library of Medicine.
  3. NHS. Leg cramps.
  4. Garrison SR, Korownyk CS, Kolber MR, et al. Magnesium for skeletal muscle cramps. Cochrane Database Syst Rev. 2020;9:CD009402.
  5. US Food and Drug Administration. Qualaquin (quinine sulfate) prescribing information, boxed warning. DailyMed, US National Library of Medicine.
  6. MedlinePlus Medical Encyclopedia. Rhabdomyolysis. US National Library of Medicine.
  7. National Heart, Lung, and Blood Institute (NHLBI). Peripheral artery disease: symptoms.
  8. National Institute of Diabetes and Digestive and Kidney Diseases (NIDDK). Hypothyroidism (underactive thyroid).
  9. National Institute of Diabetes and Digestive and Kidney Diseases (NIDDK). What is kidney failure?
  10. National Institute of Diabetes and Digestive and Kidney Diseases (NIDDK). Peripheral neuropathy.
  11. Centers for Disease Control and Prevention. About venous thromboembolism (blood clots).

Educational context only, not medical advice or a diagnosis. Always discuss your results with a clinician.