What Can I Take for Leg Cramps at Night?

For nighttime leg cramps, the most consistently supported options are calf stretching before bed, maintaining electrolyte balance, and possibly a B-vitamin complex. Despite its popularity, magnesium supplements have not shown strong results in clinical trials for nocturnal cramps specifically. Here’s what the evidence actually supports, what falls short, and what to avoid.

Stretching Works Better Than Most Supplements

The single most effective thing you can do costs nothing. Cleveland Clinic recommends a simple wall stretch: stand about three feet from a wall, lean forward with your arms outstretched and feet flat on the floor, hold for a count of five, and repeat for at least five minutes. Do this three times a day, including right before bed. This targets the calf muscles where most nocturnal cramps strike.

If a cramp hits while you’re in bed, flex your foot upward (toes toward your shin) to stretch the calf. Walking around briefly afterward can help prevent it from returning. A warm bath, hot shower, or ice massage on the affected muscle can also ease the pain once a cramp has passed.

The Magnesium Question

Magnesium is the most commonly recommended supplement for leg cramps, but the clinical evidence is surprisingly weak. A randomized crossover trial gave participants 900 mg of magnesium citrate twice daily for a month and found no significant difference compared to placebo. The average number of cramps was nearly identical in both groups (11.1 on placebo versus 11.8 on magnesium). A Cochrane systematic review of magnesium for muscle cramps found no reliable evidence supporting its use for nocturnal cramps in the general population.

That said, if you’re genuinely low in magnesium (common among older adults, people taking certain medications, or those with poor dietary intake), correcting the deficiency could still help. The issue is that taking extra magnesium when your levels are already normal doesn’t appear to reduce cramp frequency. As for topical magnesium sprays, no completed randomized trials have confirmed they work for cramps. Only one trial in dialysis patients has been registered, and its results haven’t been published.

B Vitamins Show More Promise

A randomized, double-blind trial in elderly patients with high blood pressure found that a B-vitamin complex significantly reduced the frequency, intensity, and duration of nocturnal leg cramps over three months. In that study, 86% of patients taking the B-vitamin complex experienced prominent remission of their cramps, while the placebo group showed no meaningful change. The supplement contained a combination of B1, B2, B6, and B12.

This is a single study in a specific population, so it’s not a guarantee for everyone. But it’s one of the stronger results in cramp research, and B vitamins carry very low risk for most people.

Electrolytes Matter More Than Water Alone

Dehydration is often blamed for nighttime cramps, but the relationship is more nuanced than “drink more water.” Research published in BMJ Open Sport and Exercise Medicine found that drinking plain water after dehydration actually made muscles more susceptible to cramping, likely because it dilutes sodium and other electrolytes in the blood. When participants drank a fluid containing electrolytes instead, cramp susceptibility decreased.

This means chugging water before bed isn’t necessarily the fix. If you suspect dehydration plays a role in your cramps (you sweat heavily, exercise in heat, or don’t drink much during the day), an electrolyte drink or adding a pinch of salt to your water may be more effective than water on its own. Potassium-rich foods like bananas, potatoes, and leafy greens also contribute to the electrolyte balance your muscles depend on.

Check Your Medications

Several common medications can trigger or worsen nighttime leg cramps. Diuretics (water pills) are among the most frequent culprits. Thiazide-type diuretics list muscle cramps as an adverse effect in 5% or more of users, and combining a blood pressure medication with a diuretic raises the incidence further. Even potassium-sparing diuretics, which are sometimes prescribed specifically to prevent electrolyte loss, are associated with cramping.

The mechanism likely involves the loss of potassium, magnesium, or calcium through increased urination, along with overall fluid volume reduction. If you take a diuretic or statin and your nighttime cramps started or worsened after beginning the medication, that connection is worth raising with your prescriber. A dosage adjustment or switch to a different drug class can sometimes resolve the problem entirely.

What to Avoid: Quinine

Quinine, found in tonic water and available by prescription, was once a go-to remedy for leg cramps. The FDA has explicitly stated that quinine is not considered safe or effective for treating or preventing leg cramps. It is approved only for treating malaria. The risks include a dangerous drop in blood platelet count, severe allergic reactions, and heart rhythm abnormalities. Fatalities and kidney failure requiring dialysis have been reported from quinine use for leg cramps. The small amount in a glass of tonic water is unlikely to cause harm, but it’s also unlikely to help.

Cramps During Pregnancy

Nocturnal leg cramps are especially common during pregnancy, particularly in the second and third trimesters. The Mayo Clinic recommends regular physical activity, staying well hydrated, and stretching calf muscles before bed as first-line prevention. Some research suggests that lower calcium levels during pregnancy contribute to cramping, so getting 1,000 milligrams of calcium daily (through food or supplements) is recommended.

Magnesium supplementation during pregnancy has mixed evidence, similar to the general population. If a cramp strikes, stretching the calf, walking briefly, and then elevating your legs can help it resolve and prevent recurrence.

Cramps vs. Restless Legs Syndrome

It’s worth knowing whether what you’re experiencing is actually a cramp. Nocturnal leg cramps present as sudden, painful contractions, usually in the calf, that lock the muscle tight for seconds to minutes. Restless legs syndrome feels different: it’s an uncomfortable urge to move your legs, often described as crawling, tingling, or aching, that gets worse when you’re still and improves when you move. Cramps force you awake with sharp pain. Restless legs keep you from falling asleep with persistent discomfort. The treatments for these two conditions are quite different, so distinguishing between them matters.