Leg Cramps: Causes, Magnesium, and What Really Helps

What really helps against leg cramps? Causes from magnesium deficiency and statins to diabetes and circulatory problems, treatment, and quick relief.

Sign up for free now

At a glance

Definition
a sudden, painful, involuntary muscle contraction — usually in the calf muscle, less often in the foot, thigh, or hand
Frequency
about 60 percent of adults experience nighttime leg cramps — the frequency rises markedly with age
Harmless
in over 70 percent of cases: idiopathic nighttime leg cramps with no identifiable cause, often clustering in families
Common causes
magnesium, potassium, or sodium deficiency, fluid deficiency, diuretics, statins, diabetes, thyroid, circulatory problems, pregnancy, intense exercise
When to see a doctor
frequent cramps (>2x/week), one-sided swelling, pain on walking, neurological accompanying symptoms, new medications, diabetes with worsening
ICD-10
R25.2 (cramp and spasm), M62.83 (muscle spasm)

1. What are leg cramps?

Leg cramps — medically crampi or muscle cramps — are sudden, painful, involuntary muscle contractions that usually affect the calf muscle, occasionally also the foot, thigh, or hand muscles. The cramp typically lasts a few seconds to minutes — feeling like an eternity — and often leaves a muscular soreness afterward that can last hours to days.

Leg cramps are among the most common complaints of all. About 60 percent of adults experience nighttime leg cramps at least once a year, and from age 60 it is nearly 80 percent. In younger people they occur mainly in connection with exercise, pregnancy, or certain medications — in older people, usually at night, with no clearly identifiable trigger.

In most cases, leg cramps are harmless and easily treated — whether through simple immediate measures such as stretching, through a change in lifestyle, or through targeted drug treatment. At the same time, however, they can also be a pointer to serious underlying conditions: diabetes with polyneuropathy, circulatory problems, electrolyte derailments, or thyroid disorders. A medical evaluation is therefore worthwhile with frequent or newly appeared cramps.

2. How does a leg cramp arise physiologically?

A leg cramp arises from an excessive excitability of the motor nerve endings in the affected muscle. Normally, an electrical impulse from the spinal cord triggers a controlled muscle contraction that is released again once the task is done. In a cramp, however, the nerve ending discharges uncontrollably and repetitively — the muscle contracts maximally and stays locked in this state until stretching or increased inhibitory signals release it.

The exact mechanisms are not fully understood, but several factors demonstrably play a role: electrolyte shifts (magnesium, potassium, sodium, calcium) change the electrical excitability of the nerves. Dehydration reduces the volume in the muscle tissue and concentrates metabolic products. Muscle fatigue and a shortened muscle length (e.g. with long sitting with a pointed foot) increase the readiness to cramp. Circulatory problems reduce the supply of oxygen and nutrients and accelerate the build-up of acid.

From this understanding follow the most important therapeutic levers: stretching interrupts the cramp acutely, an electrolyte balance and enough fluids act preventively, and targeted treatment of an underlying disease removes the cause.

3. Nighttime leg cramps: the most common form

Idiopathic nighttime leg cramps are by far the most common form — they have no clearly identifiable cause and are regarded as a condition in their own right. They typically occur out of sleep, usually in the second half of the night, often after lying for a long time with a pointed foot (plantar flexion). The cramp wakes you abruptly, can be very painful, and noticeably disrupts sleep quality.

Risk factors: older age, female sex, preceding intense physical activity, long standing, too-tight bedding (which pushes the feet into plantar flexion), family history — and of course underlying conditions such as diabetes, thyroid disorders, chronic kidney disease, or liver disease.

Prevention: stretch the calf muscle for 1–2 minutes before going to bed (see the immediate-relief section), drink enough during the day, not too much alcohol in the evening, do not tuck the foot end of the bedding in too tightly, regular moderate exercise. In studies, daily evening calf stretching alone reduces the frequency of nighttime cramps by about 30 to 50 percent.

4. Leg cramps during exercise

During exercise, leg cramps occur particularly often in two situations: at the end of long, intense exertion (marathons, long cycling, triathlon) and with unaccustomed exertion without adequate preparation. The cause in these cases is usually a combination of muscle fatigue, dehydration, and electrolyte loss through sweating.

A classic example: a marathon runner who feels the first cramp symptoms from kilometer 30 and gets a full cramp in the final sprint. Studies show: athletes with frequent exertion cramps often have a lower cramp threshold in their motor nerve endings — a constitutional factor that can be influenced through training, mineral balance, and targeted stretching.

What helps: adequate fluid and electrolyte intake during exertion (isotonic sports drinks for long sessions), gradually increasing the load, regular stretching of the calf muscle, and magnesium supplementation if a deficiency is documented. With recurring cramps, a sports-medicine examination with an electrolyte analysis before and after exertion is worthwhile.

5. Electrolyte and fluid deficiency

Magnesium deficiency

The best-known suspect — and at the same time the most frequently overrated. A documented magnesium deficiency does indeed cause leg cramps (common with chronic alcohol use, diabetes, diuretic treatment, diarrhea, or malabsorption). In people without a deficiency and with normal lab values, however, studies show a rather limited effect of magnesium on leg cramps. Even so, supplementation is sensible in many cases — because of its good tolerability and low risk.

Potassium deficiency (hypokalemia)

Potassium loss is a very common and often overlooked cause of leg cramps — especially with diuretic treatment (loop diuretics such as furosemide, thiazides such as hydrochlorothiazide), with chronic diarrhea, vomiting, laxative misuse, or with primary aldosteronism. A simple measurement of the potassium level in the blood clarifies the suspicion — values below 3.5 mmol/l need treatment.

Sodium deficiency (hyponatremia)

Rare, but relevant — especially in older people on diuretics, with excessive drinking ("water intoxication" in marathon runners), with heart failure, or with disorders of the hormone ADH (SIADH). Leg cramps here are usually combined with confusion, headache, and nausea.

Calcium deficiency and vitamin D deficiency

A pronounced calcium deficiency can lead to typical carpopedal spasms of the hands and to leg cramps (tetany). Causes: vitamin D deficiency, underactive parathyroid glands, chronic kidney failure. Vitamin D deficiency alone is very common and can contribute to an increased readiness to cramp — measuring the 25-OH vitamin D level is worthwhile especially in winter.

Dehydration

Drinking too little — especially in older people with a reduced sense of thirst and on diuretics — is a common, easily remedied cause. About 1.5 to 2 liters a day are recommended, more with physical activity or hot weather. An important exception: with severe heart or kidney failure, different fluid amounts apply — please clarify with a doctor.

6. Leg cramps from statins

Statins (atorvastatin, simvastatin, rosuvastatin, pravastatin) are among the most prescribed medications in the world and effectively lower LDL cholesterol — they are a central pillar of preventing heart attacks and strokes. A statin-associated myopathy, however, is a known and not-rare side effect: muscle pain, muscle weakness, leg cramps.

Frequency and course: in randomized studies, 7 to 10 percent of statin users complain of muscle symptoms — many of which, however, also occurred under placebo (the nocebo effect). True muscular side effects typically appear within the first 6 months, often dose-dependent, more often in women, older people, those with low body weight, hypothyroidism, high alcohol use, or in combination with other medications (e.g. gemfibrozil, ciclosporin, macrolide antibiotics).

What to do: with a suspicion, see a doctor for measurement of creatine kinase (CK) — with markedly raised values, the statin must be stopped immediately, because in the worst case there is a risk of rhabdomyolysis (muscle breakdown with kidney damage). With normal CK and persistent complaints: a dose reduction, a switch to a different statin, or a switch to alternative lipid-lowering drugs (e.g. ezetimibe, PCSK9 inhibitors). Coenzyme Q10 as a supplement is often recommended — the evidence is limited, but its use is safe.

Never stop statins on your own! The benefit clearly outweighs the risks when correctly indicated. Having the complaints clarified by a doctor and, if needed, switching to an alternative substance is the right way to go. More: high cholesterol.

7. Leg cramps from diuretics and other medications

A wide range of medications can cause leg cramps as a side effect — usually via electrolyte shifts, neuromuscular effects, or microcirculation problems. Particularly relevant:

  • Loop diuretics (furosemide, torasemide) — a typical and common cause, especially in higher doses
  • Thiazides (hydrochlorothiazide, indapamide) — a very common cause, especially with long-term use
  • Beta-2 agonists (salbutamol/albuterol, formoterol for asthma/COPD) — via a shift of potassium into the cells
  • Insulin in high doses — also via a potassium shift
  • Glucocorticoids in higher doses — potassium loss
  • Statins — see the previous section
  • Thyroid hormones when overdosed
  • Bisphosphonates for osteoporosis — can promote calcium shifts
  • Antibiotics (fluoroquinolones, penicillins in high doses) — increased neuromuscular excitability
  • Chemotherapy drugs (vincristine, cisplatin) — peripheral neuropathy with cramps
  • Hormones and contraceptives — can trigger cramps in some women
  • Donepezil and other cholinesterase inhibitors for dementia

Important: never stop suspect medications on your own — many patients absolutely need the treatment. A medical evaluation with electrolyte measurement and, if needed, a dose adjustment or switch is the right way to go. More: drug interactions, taking medication correctly.

8. Diabetes and neurological causes

With diabetes, leg cramps are a common accompanying symptom — especially in the context of diabetic polyneuropathy. This nerve damage affects about 30 to 50 percent of all long-standing diabetics and shows itself, besides cramps, with tingling, numbness, burning pain especially at night, and sensory disturbances. Good blood sugar control slows the progression but usually cannot reverse existing damage.

Other neurological causes of cramps: amyotrophic lateral sclerosis (ALS) — very rare, but important to know, since leg cramps and fasciculations (muscle twitches) can be among the early signs. Multiple sclerosis, herniated discs with irritation of the nerve roots (especially L5/S1 — typically one-sided), polyneuropathies of other causes (alcohol, vitamin B12 deficiency, thyroid, kidney failure). With any persistent or progressive symptom pattern, a neurological evaluation should be done.

9. Circulatory problems (PAD)

Peripheral arterial disease (PAD) is an important and often-overlooked cause of leg cramps — especially in smokers, diabetics, patients with high blood pressure, and older people. Characteristic is intermittent claudication ("window-shopping disease"): cramp-like calf pain that appears on walking after a reproducible distance and quickly disappears again when standing — so-called walking-distance complaints.

Difference from typical leg cramps: PAD cramps occur under exertion and stop at rest, whereas idiopathic nighttime cramps occur at rest (lying down). With PAD, the foot pulse is often missing, the skin is cool, the hair is reduced. A medical evaluation includes the ankle-brachial index (ABI) and, if needed, Doppler ultrasound and angiography. Treatment: consistent reduction of risk factors (stop smoking!), walking training, antiplatelet agents, and, if needed, interventional opening of blocked vessels.

Seek medical help immediately for sudden one-sided calf swelling with redness, warmth, and pain — suspected deep vein thrombosis with a risk of pulmonary embolism. Also with sudden severe calf pain with no pulse, a feeling of cold, and pale skin (suspected acute arterial occlusion), call 112 immediately (in the UK, 999 or 112).

10. Leg cramps in pregnancy

Leg cramps are a very common complaint in pregnancy — about 30 to 50 percent of pregnant women are affected, usually from the second trimester. Causes are changes in calcium and magnesium metabolism, increased pressure on the leg veins, changes in muscle physiology, and an increased need for fluids.

What helps in pregnancy: magnesium supplementation (300–360 mg/day) has shown a moderate but consistent effect in studies and is the standard recommendation. Optimize calcium and vitamin D supply. Regular calf stretching before going to bed. Drink enough. Avoid long sitting or standing without movement breaks. With cramps that cannot be remedied — especially with swelling — see a doctor because of the increased risk of thrombosis.

11. Leg cramps in older people

With increasing age, the frequency of leg cramps rises markedly — from age 60 about 50 percent suffer from them regularly, from age 80 up to 80 percent. Several factors act together: a reduced sense of thirst with chronic dehydration, several long-term medications with cramp potential, pre-existing conditions such as diabetes or kidney failure, decreasing muscle mass (sarcopenia), less exercise, and a shortened calf muscle from long sitting.

Therapeutic approach in older people: critically review the medication list (reduce polypharmacy), measure electrolytes and vitamin D, ensure enough fluids (provided heart and kidney function allow it), regular calf stretching and moderate exercise, and, if needed, low-dose magnesium or, as a second line, a cramp prophylactic such as quinine sulfate (only under medical supervision, because of rare side effects).

12. When to see a doctor (warning signs)

See a doctor promptly if:

  • cramps occur very frequently (more than 2–3 times a week)
  • cramps are new after starting a new medication
  • there are accompanying symptoms such as swelling, redness, or warmth of the leg (suspected thrombosis)
  • cramps occur on walking after a reproducible distance (suspected PAD)
  • there is accompanying weakness, numbness, tingling, or burning pain (neuropathy)
  • cramps come with a marked general deterioration, weight loss, or fatigue
  • cramps occur with known diabetes and a worsening metabolic situation
  • cramps come with muscle pain and weakness while on statin treatment
  • there is very severe and lasting muscle pain with dark urine (suspected rhabdomyolysis)
Seek medical help immediately for sudden one-sided painful calf swelling with redness and warmth — suspected deep vein thrombosis with a risk of pulmonary embolism. With sudden severe calf pain with no pulse, a feeling of cold, and pale skin (acute arterial occlusion), also call 112 immediately (in the UK, 999 or 112).

13. Diagnosis: what the doctor does

The medical evaluation follows a step-by-step scheme:

  • History: frequency, time of day, triggers, accompanying symptoms, medications, pre-existing conditions, lifestyle (alcohol, exercise, fluid intake)
  • Clinical examination: pulses, skin findings, reflexes, sensation, muscle strength, leg circumference compared side to side
  • Basic laboratory tests: electrolytes (sodium, potassium, calcium, magnesium), complete blood count, CRP, TSH, HbA1c, kidney and liver values, creatine kinase (CK) if taking statins, vitamin D, and vitamin B12 if needed
  • If PAD is suspected: ankle-brachial index (ABI), Doppler ultrasound, and angiography if needed
  • If thrombosis is suspected: D-dimers, Doppler ultrasound of the leg veins
  • Neurological evaluation: electromyography (EMG) and nerve conduction velocity (NCV) if polyneuropathy or ALS is suspected
  • Extended workup depending on suspicion: thyroid antibodies, parathyroid hormone (parathyroid gland), tumor markers if paraneoplastic syndromes are suspected

More: preparing for a doctor's appointment, understanding blood test results.

14. Immediate relief for an acute cramp

What really helps in the moment of a cramp — tried-and-tested and fast-acting:

  • Stretch immediately: straighten the leg, actively pull the toes toward the shin with your hand — hold until the cramp eases. This is by far the most effective immediate relief.
  • Stand up and step carefully: shifting the weight onto the forefoot automatically stretches the calf muscle — often quickly effective for nighttime cramps.
  • Gentle massage: massage the cramped muscle with the pressure of a flat hand — painful at first, but it helps to release the cramp.
  • Warmth: a warm cloth or a hot water bottle relaxes the muscle after the acute cramp and reduces the soreness afterward.
  • Cold for very severe pain: as an alternative for muscular soreness after the cramp — for an acute cramp, warmth is better.
  • Drink: a glass of water or an electrolyte drink helps with dehydration-related cramps.
  • Do not massage with swelling and redness: suspected thrombosis — then have it evaluated by a doctor.

15. Prevention and treatment

The long-term strategy against leg cramps rests on three pillars: lifestyle, mineral balance, and medications if needed.

Lifestyle

  • Daily calf stretching: 30–60 seconds per side, in the morning and before going to bed — the best scientifically supported measure
  • Drink enough: 1.5–2 liters a day — more with exercise or heat (exception: heart and kidney failure)
  • Regular moderate exercise: walks, swimming, cycling — strengthens the muscles and circulation
  • A balanced diet: whole grains, legumes, nuts, bananas, green vegetables, dairy products — natural sources of magnesium, potassium, and calcium
  • Cut down on alcohol: increases both the readiness to cramp and the loss of magnesium
  • Comfortable footwear and enough movement breaks with long sitting

Drug treatment

  • Magnesium: 300–400 mg/day orally as citrate, glycinate, or malate — a moderate but consistent effect
  • Vitamin D with a documented deficiency
  • Potassium supplementation with documented hypokalemia
  • Quinine sulfate: only in exceptional cases for the most severe treatment-resistant cramps — used very cautiously because of rare severe side effects (thrombocytopenia, heart rhythm disturbances)
  • Coenzyme Q10: as supportive treatment for statin-associated complaints, moderate evidence
  • B vitamins: sensible with a documented polyneuropathy

16. Magnesium: what really helps

Magnesium is by far the best-known and most frequently used supplement for leg cramps — the evidence, however, is nuanced:

When magnesium clearly helps: with a documented magnesium deficiency (serum magnesium below 0.7 mmol/l), with diuretic treatment, with chronic alcohol use, with diabetes, in pregnancy. In these constellations the effect is well documented and magnesium is an established standard.

When the effect is limited: with idiopathic nighttime leg cramps without a documented deficiency. Studies here show a rather weak effect beyond placebo. Even so, many people subjectively report improvement — the trial over 4 to 6 weeks is justifiable because of the low side effects.

Which magnesium preparation: organic compounds such as magnesium citrate, magnesium glycinate, or magnesium malate are absorbed considerably better than inorganic ones (magnesium oxide, carbonate). Dose: 300–400 mg of elemental magnesium per day, best in the evening. Main side effect: soft stool or diarrhea with too high a dose.

Caution with impaired kidney function — here magnesium accumulation can occur. Talking to a doctor is sensible. Magnesium also has several interactions: it should be taken 2 hours apart from levothyroxine, iron supplements, and tetracycline and fluoroquinolone antibiotics.

How brite helps you with leg cramps

brite supports you in better understanding leg cramps and keeping track of your medications.

  • Intake reminders — take magnesium, potassium supplements, vitamin D, or prescribed medications on schedule: brite reminds you on time. Set up a reminder
  • Interaction check — check statin, diuretic, and magnesium interactions for free — especially the spacing from levothyroxine and antibiotics. Check now
  • Health journal — document a cramp diary with frequency, time of day, triggers, and accompanying symptoms over time — valuable for the medical workup.
  • Digital medication plan — all your medications clearly laid out for your GP, cardiologist, diabetologist, and pharmacy. Go to the medication plan
Get started for free now
brite app

FAQ: Common questions

With a documented magnesium deficiency or risk factors (diuretics, diabetes, alcohol, pregnancy), the effect is well established. With idiopathic nighttime cramps without a deficiency, magnesium shows only a weak but consistent effect in studies — the trial over 4 to 6 weeks with 300–400 mg of organic magnesium (citrate or glycinate) is well justifiable because of its low side effects.
Immediately straighten the leg and actively pull the toes toward the shin with your hand — this stretch of the calf muscle usually releases the cramp within seconds. Alternatively, stand up and step carefully. After the cramp, gentle massage and warmth reduce the soreness. A glass of water or an electrolyte drink helps with dehydration-related cramps.
Exertion cramps usually arise from a combination of muscle fatigue, dehydration, and electrolyte loss through sweating — especially with long exertion (marathons, triathlon, mountain hikes) or unaccustomed effort. Athletes with frequent cramps often have a lower cramp threshold and benefit from a gradual build-up, isotonic fluids during exertion, and targeted stretching.
Yes — a statin-associated myopathy with muscle pain, muscle weakness, and leg cramps occurs in about 7 to 10 percent of users. With a suspicion, see a doctor for measurement of creatine kinase (CK). Important: never stop statins on your own — the benefit for the heart and vessels is high when correctly indicated. A dose adjustment, a switch of statin, or a switch to alternative lipid-lowering drugs are established solutions.
A leg cramp becomes an emergency when it comes with sudden one-sided calf swelling, redness, and warmth — suspected deep vein thrombosis with a risk of pulmonary embolism. Also an emergency: sudden severe calf pain with no pulse, a feeling of cold, and pale skin (acute arterial occlusion). In both cases, call 112 (in the UK, 999 or 112) or go to the nearest emergency department immediately.
The tradition of pickle juice in professional sport actually has a plausible explanation: the sour taste activates receptors in the mouth and throat that reflexively, via the vagus nerve, reduce the readiness of the calf muscle to cramp — the effect sets in faster than through electrolyte intake. Salt water helps with dehydration and sodium deficiency, but should be used with caution with high blood pressure and heart failure.
Occasional leg cramps (1–2 times a month) are very common and usually harmless. If they occur more than 2–3 times a week, considerably disrupt sleep, or come with other symptoms (swelling, weakness, numbness), a medical evaluation is worthwhile — especially in older people, diabetics, and those on diuretic or statin treatment.
Magnesium supplementation (300–360 mg/day) is the standard recommendation and has a moderate effect in studies. In addition: daily calf stretching before going to bed, drinking enough, optimizing calcium and vitamin D supply, and avoiding long standing or sitting without breaks. With swelling or severe one-sided pain, always see a doctor because of the increased risk of thrombosis.
Not necessarily, but: frequent leg cramps can be a pointer to diabetic polyneuropathy — especially in combination with tingling, numbness, burning pain, or disturbed sensation in the feet. With recurring leg cramps that have no known cause, a blood sugar and HbA1c test should therefore be done. With known diabetes and increasing cramps, too, an adjustment of treatment and a neurological evaluation are sensible.

Sources

  1. S1 Guideline Crampi/Muscle Cramp (AWMF 030-037), Germany. — https://www.awmf.org/leitlinien/detail/ll/030-037.html
  2. IQWiG — gesundheitsinformation.de: Muscle Cramps, Leg Cramps. — https://www.gesundheitsinformation.de/
  3. National Care Guideline Chronic Coronary Heart Disease — Statin Treatment and Myopathy (AWMF nvl-004), Germany. — https://www.leitlinien.de/themen/khk
  4. German Society of Neurology (DGN) — Polyneuropathies. — https://www.dgn.org/
  5. Drug Commission of the German Medical Association (AkdÄ) — Leg Cramps and Medications. — https://www.akdae.de/
Note: This article is for general information and does not replace medical advice, diagnosis, or treatment. With frequent or newly appeared leg cramps, especially while on medications or with accompanying symptoms, a medical evaluation should be done. For sudden one-sided painful calf swelling with redness and warmth, call the emergency number immediately — 112 across the EU, or 999/112 in the UK — as this may indicate a deep vein thrombosis with a risk of pulmonary embolism. Never stop statins on your own.