
Most muscle cramps have no single cause you can point to. Doctors call these idiopathic cramps, and they make up the majority — including the calf cramps that jolt people awake at night [Allen & Kirby, 2012]. So the honest answer to what causes muscle cramps comes in two parts: everyday triggers that make a cramp more likely, and a shorter list of medicines and medical conditions worth ruling out if cramps keep coming back.
A cramp is a sudden, involuntary tightening of a muscle that won’t let go when you tell it to. The calf is the classic spot, though the thigh and foot cramp too. Night leg cramps are remarkably common: 50 to 60 percent of adults say they’ve had them, and they get more frequent with age [Allen & Kirby, 2012]. An episode lasts about nine minutes on average, and the muscle can stay sore, or cramp again, for hours afterward.
What causes muscle cramps: the everyday triggers

Mayo Clinic lists overusing or straining a muscle, losing fluid through sweat, and holding one position for a long time as common triggers — while noting that often the cause is simply unknown [Mayo Clinic, 2023]. Some people are more prone than others. Risk rises with age (as muscle mass declines), poor conditioning, heavy sweating in hot weather, pregnancy, carrying extra weight, and illnesses such as diabetes or conditions affecting the nerves, liver, or thyroid [Mayo Clinic, 2023].
Fatigue and overuse
For cramps that strike during or just after exercise, the best-supported explanation is muscle fatigue. As a muscle tires, the nerve signals that excite it and the reflexes that normally calm it get out of balance, and the muscle locks up. A review in the British Journal of Sports Medicine found this “altered neuromuscular control” explanation backed by lab cramp models, studies of cramping athletes, and animal work [Schwellnus, 2009]. It also explains something the dehydration theory struggles with: exercise cramps hit the specific muscles that are working hardest, not muscles all over the body [Miller et al., 2022].

Dehydration and electrolytes: less clear than you’ve heard
This is where sources genuinely disagree. MedlinePlus, the National Library of Medicine’s consumer site, says dehydration and low sodium, potassium, or calcium raise the risk of cramps, especially during exercise [MedlinePlus, 2026]. But a clinical review for family physicians states that neither exercise cramps nor night cramps have been linked to dehydration or to abnormal potassium, sodium, or magnesium levels, and that routine blood tests for electrolytes aren’t useful [Allen & Kirby, 2012]. The sports-medicine review mentioned above found that the evidence for the dehydration and electrolyte theory rests mostly on anecdotes, case series totaling 18 people, and one 10-person study [Schwellnus, 2009].
What this means for you: drinking enough fluid in hot weather and during long workouts is still sensible. But if you cramp even when you’re well hydrated, fatigue, conditioning, or one of the causes below is the likelier culprit — and loading up on electrolyte drinks probably won’t fix it.
Medical conditions linked to cramps
Frequent or severe cramps sometimes point to an underlying problem. The conditions most often linked to them include:
| Condition | What you might notice |
| Narrowed leg arteries (peripheral artery disease) | Cramping in the legs during exercise that usually eases once you stop [Mayo Clinic, 2023] |
| Pressure on spinal nerves (lumbar stenosis) | Leg cramps that often get worse the longer you walk [Mayo Clinic, 2023] |
| Low potassium, calcium, or magnesium | Can follow heavy diarrhea or vomiting, or some blood-pressure medicines that increase urination [Mayo Clinic, 2023] |
| Thyroid, liver, or kidney disease | Hypothyroidism, cirrhosis, kidney failure, and dialysis are all associated with cramps [MedlinePlus, 2026], [Allen & Kirby, 2012] |
| Nerve conditions | Peripheral neuropathy and parkinsonism; diabetes raises risk partly through nerve damage [Allen & Kirby, 2012], [Mayo Clinic, 2023] |
| Pregnancy | Leg cramps are common, especially later in pregnancy [Luo et al., 2020] |
| Alcohol use disorder | Listed among recognized triggers [MedlinePlus, 2026] |
Medications that can bring on cramps
Medicines are an underrated cause. A large population study from British Columbia found that people were substantially more likely to start treatment for leg cramps in the year after beginning a long-acting beta-agonist inhaler (used for asthma and COPD), a potassium-sparing diuretic, or a thiazide-like diuretic. The links for statins and loop diuretics were small [Garrison et al., 2012].
Not every source agrees on diuretics: the 2012 family-physician review noted that evidence-based reviews at the time hadn’t implicated them, even though many people believe they cause cramps [Allen & Kirby, 2012]. The same review lists other drugs with reported cramp rates, including intravenous iron sucrose, conjugated estrogens, raloxifene, naproxen, teriparatide, and pregabalin.
If your cramps started around the time you began a new medicine, mention it to your prescriber. Don’t stop a prescribed drug on your own — there is often an alternative, or a dose change, that solves the problem safely.
Is it a cramp, or something else?
A true cramp is sudden, painful, and you can usually see or feel the muscle knotted hard. A few conditions are easily confused with it [Allen & Kirby, 2012]:
- Restless legs syndrome: an irresistible urge to move your legs, usually in the evening, that eases when you move. Uncomfortable, but not a painful knot.
- Claudication: aching or cramping that comes on with walking and goes away with rest — a sign of reduced blood flow.
- Statin-related muscle problems or myositis: deep, aching pain with weakness and poor exercise tolerance, rather than brief spasms.
- Peripheral neuropathy: numbness, tingling, or “electric” pain unrelated to exercise or sleep.
If older adults in your family deal with persistent leg pain that doesn’t fit the cramp pattern, our guide to chronic pain management for seniors covers how to assess it and work with their care team.
How to stop a muscle cramp right now
Stretch the cramping muscle gently and hold it until the cramp lets go. For exercise cramps, this is the best-supported treatment available [Miller et al., 2022]. For a calf cramp, straighten your knee and pull your toes up toward your shin — with your hand, a towel, or by standing and leaning into a wall with the cramped leg behind you. Go gently; yanking a cramped muscle hurts and doesn’t speed things up.

Massage helps too. MedlinePlus suggests heat when the spasm starts and ice once the pain begins to ease, and an over-the-counter pain reliever if the muscle stays sore afterward [MedlinePlus, 2026].
Pickle juice has some evidence behind it. Small amounts of vinegar-containing or spicy foods may cut an exercise cramp short — apparently through a nerve reflex triggered in the mouth and throat, since the effect appears faster than any electrolytes could be absorbed. The evidence is limited; the review that graded it recommends using it only occasionally, in amounts under 100 mL, and not if you’re allergic to the ingredients [Miller et al., 2022].
How to prevent muscle cramps
Stretch before bed. In a randomized trial of 80 adults over 55 with night leg cramps, those who stretched their calves and hamstrings every night just before sleep had fewer and less painful cramps than those who didn’t [Hallegraeff et al., 2012]. It’s one trial, and the wider evidence for stretching is limited [Allen & Kirby, 2012], but stretching is free and harmless, which makes it the obvious first thing to try. A few minutes of light exercise before bed, such as gentle cycling on a stationary bike, may also help [Mayo Clinic, 2023].
A simple routine: stand facing a wall with your hands on it, step one foot back, keep that heel on the floor and the knee straight, and lean in until you feel a steady pull in the calf. Hold, release, and repeat on both sides. Add a seated hamstring stretch, reaching toward your toes with your legs straight.

Mind your sleeping position. One theory is that lying with your foot pointed leaves the calf already shortened, which makes it easier to cramp [Allen & Kirby, 2012]. Loosening tightly tucked sheets so they don’t press your toes down, or sleeping with your feet relaxed rather than pointed, hasn’t been formally tested, but it costs nothing.
Drink fluids regularly through the day and during activity [Mayo Clinic, 2023]. Even if dehydration isn’t the main driver for most cramps, it’s rarely a good idea to exercise dry.
For athletes, build fitness for the work you’re asking of your muscles. If cramps show up late in games or races, the likely issue is fatigue. Strength and neuromuscular training, practicing at the intensity and in the conditions you compete in, and enough rest between sessions are the prevention steps with the best support [Miller et al., 2022]. For a broader look at muscle and joint problems, see our guide to natural approaches for musculoskeletal disorders.
Do foods or supplements help with muscle cramps?
This is where expectations most need resetting. Eating well supports your muscles, but no food or supplement has been shown to reliably prevent cramps in most people.
Magnesium
Magnesium is the most popular cramp remedy, and it has been tested properly. A 2020 Cochrane review pooled 11 trials involving 735 people. For older adults with ordinary, unexplained cramps, magnesium did no better than placebo, and the reviewers concluded it is unlikely to offer meaningful protection [Garrison et al., 2020]. For cramps in pregnancy, the results were inconsistent and the evidence is very uncertain [Garrison et al., 2020], [Luo et al., 2020]. No trials have tested magnesium for exercise cramps [Garrison et al., 2020].

Magnesium still matters for overall health, and food is the best way to get it. Seeds such as sesame and pumpkin, nuts, beans, leafy greens, and whole grains are rich sources — our guide to magnesium-rich foods ranks them by serving. If you are low in magnesium because of an illness or medication, that is a different situation, and one for your clinician to test and treat.
Potassium, calcium and B vitamins
Potassium-rich foods such as bananas and orange juice are part of MedlinePlus’s home-care advice [MedlinePlus, 2026], and our potassium-rich foods chart lists better sources than bananas alone. Potassium pills are a different matter: the family-physician review found no support for routine potassium or calcium supplements for cramps [Allen & Kirby, 2012]. In pregnancy, calcium did not consistently reduce cramps [Luo et al., 2020].
Vitamin B12 complex may help some people with night cramps, but the evidence is low quality [Allen & Kirby, 2012]. One small pregnancy trial found more women recovered fully on a B-vitamin supplement, but its design had limitations [Luo et al., 2020].
Sports drinks
During long or hot workouts, a carbohydrate-electrolyte drink is a reasonable choice, ideally matched to how much you sweat [Miller et al., 2022]. The same review cautions that sports drinks can’t replace all electrolyte losses, and that drinking far more than you need can dangerously dilute the sodium in your blood.
Safety: supplements, pregnancy, and why quinine is off the table
Magnesium supplements. The upper limit for adults from supplements and medicines is 350 mg a day; magnesium in food doesn’t count toward it. Too much can cause diarrhea, nausea, and stomach cramps, and extremely high intakes can cause an irregular heartbeat [NIH ODS, 2021]. In the Cochrane trials, diarrhea and nausea were the main complaints [Garrison et al., 2020].
Interactions. Magnesium can reduce absorption of bisphosphonates (osteoporosis drugs) and some antibiotics if taken too close together. Some diuretics, long-term acid-reflux medicines, and high-dose zinc affect magnesium levels [NIH ODS, 2021]. Your kidneys clear excess magnesium, so if you have kidney disease, ask your clinician before taking any.
Pregnancy and breastfeeding. Leg cramps are common in pregnancy, but no oral supplement — magnesium, calcium, vitamin D, B or C — has clearly been shown to be effective and safe for them, and the trials didn’t report effects on the pregnancy or baby [Luo et al., 2020]. Talk to your midwife or obstetrician before taking anything. Stretching and massage are low-risk alternatives.
Quinine. Quinine was once a common prescription for night cramps. The FDA has not approved it for that use and warns against it: between 2005 and 2008 it received 38 reports of serious reactions, including dangerously low platelet counts and kidney damage, and two deaths [FDA, 2010]. The sports-medicine review also advises against quinine-containing products such as tonic water for cramps [Miller et al., 2022].
When to see a doctor about muscle cramps

Most cramps go away on their own and need no treatment. Get checked by a health care provider if your cramps [Mayo Clinic, 2023], [MedlinePlus, 2026]:
- cause severe discomfort, or last a long time
- come with swelling, redness, or skin changes in the leg — get seen promptly
- come with muscle weakness
- happen often, or keep coming back
- don’t improve with stretching and other self-care
Also mention cramps that come on with walking and ease with rest, cramps that began after starting a new medicine, and cramps alongside numbness, tingling, or symptoms of thyroid, liver, or kidney trouble. A short history and exam are usually enough to sort out the cause; routine blood tests often aren’t needed [Allen & Kirby, 2012].
HEALTH DISCLAIMER: This article is for general education and is not a substitute for advice, diagnosis, or treatment from a qualified health professional. Muscle cramps can occasionally signal a medical condition or a medication side effect. Talk to your doctor or pharmacist before starting a supplement, especially if you are pregnant or breastfeeding, have kidney disease, or take prescription medicines — and never stop a prescribed medicine without medical advice. If you have leg swelling, redness, or sudden weakness, seek medical care promptly.
Frequently Asked Questions
Why do I get muscle cramps at night?
Most night leg cramps have no identifiable cause. They become more common with age and in pregnancy, and some medicines — notably long-acting asthma inhalers and certain diuretics — are linked to them [Allen & Kirby, 2012], [Garrison et al., 2012]. Nightly calf and hamstring stretching is the simplest thing to try first.
Does magnesium help leg cramps?
For most adults, probably not. A Cochrane review found magnesium was unlikely to give older adults meaningful relief from ordinary cramps; evidence in pregnancy is uncertain [Garrison et al., 2020]. It may help if a clinician has confirmed you are actually low in magnesium.
Are muscle cramps a sign of dehydration?
Sometimes, but less often than people assume. Heavy sweating can contribute [Mayo Clinic, 2023], yet studies haven’t consistently linked cramps to dehydration or blood electrolyte levels, and muscle fatigue is the stronger explanation for exercise cramps [Schwellnus, 2009].
Does pickle juice really work for cramps?
It may shorten an exercise cramp, likely through a reflex rather than by replacing salt. Evidence is limited, so use small amounts occasionally [Miller et al., 2022].
Is tonic water good for leg cramps?
No. Tonic water contains quinine, and quinine-containing products aren’t recommended for cramps [Miller et al., 2022]. Prescription quinine carries an FDA warning for this use [FDA, 2010].
References
- Allen RE, Kirby KA. Nocturnal leg cramps. Am Fam Physician. View source
- Garrison SR, Korownyk CS, Kolber MR, et al. Magnesium for skeletal muscle cramps. View source
- Garrison SR, et al. Nocturnal leg cramps and prescription use that precedes them: a sequence symmetry analysis. View source
- 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. View source
- Luo L, Zhou K, Zhang J, Xu L, Yin W. Interventions for leg cramps in pregnancy. View source
- Mayo Clinic. Muscle cramp — Symptoms and causes. View source
- MedlinePlus Medical Encyclopedia. Muscle cramps. View source
- Miller KC, McDermott BP, Yeargin SW, Fiol A, Schwellnus MP. An evidence-based review of the pathophysiology, treatment, and prevention of exercise-associated muscle cramps. View source
- NIH Office of Dietary Supplements. Magnesium: View source
- Schwellnus MP. Cause of exercise associated muscle cramps (EAMC) — altered neuromuscular control, dehydration or electrolyte depletion? View source
- U.S. Food and Drug Administration. FDA Drug Safety Communication: New risk management plan and patient Medication Guide for Qualaquin (quinine sulfate). View source
