Nighttime leg cramps can often be reduced or relieved with a combination of stretching, staying hydrated, and in some cases, supplements like magnesium or B vitamins. No single remedy works for everyone, and no medication is strongly recommended by clinical guidelines, but several options have enough evidence to be worth trying.
Stretching Before Bed
The simplest and most consistently recommended approach is a calf stretch done before you go to sleep. Stand facing a wall with your hands against it, step one foot back, and press that heel into the floor while keeping the leg straight. Hold for 30 to 60 seconds, then switch legs. Doing this nightly can reduce both the frequency and intensity of cramps. If a cramp wakes you up, the same stretch can help release it in the moment: flex your foot so your toes point toward your shin rather than away from it, which forces the cramping calf muscle to lengthen.
Walking around for a minute or two after a cramp hits also helps the muscle relax. Some people find that massaging the cramped muscle with firm pressure shortens the episode. A warm towel or heating pad applied afterward can ease residual soreness, though there’s no strong data on specific temperatures or durations.
Hydration and Electrolytes
Dehydration is one of the most common and correctable triggers for nighttime leg cramps. Cleveland Clinic recommends drinking about eight glasses of water per day and limiting alcohol and caffeine, both of which pull fluid from your body. If you exercise in the evening, sweat heavily, or take a diuretic medication, your fluid and electrolyte needs are higher than average.
Electrolytes like potassium, sodium, and calcium all play a role in muscle contraction and relaxation. You don’t necessarily need a sports drink. Eating potassium-rich foods (bananas, potatoes, leafy greens) and getting adequate calcium from dairy or fortified alternatives covers most people’s needs. If you suspect your diet is low in these minerals, a basic electrolyte supplement or even a glass of pickle juice (a popular folk remedy with some trial support) may help.
Magnesium Supplements
Magnesium is the supplement most commonly associated with leg cramp relief, but the clinical evidence is mixed. A large randomized, double-blind trial of 184 patients tested 226 mg of magnesium oxide taken once daily against a placebo and found limited benefit. Other smaller studies have shown modest improvements, particularly in pregnant women. The overall picture: magnesium likely helps some people, especially those whose levels are low to begin with, but it’s not a guaranteed fix.
If you want to try it, magnesium citrate or magnesium glycinate are generally better absorbed than magnesium oxide. Most trials use doses between 200 and 400 mg per day. Higher doses can cause loose stools, which is the most common side effect. Give it at least two to four weeks before deciding whether it’s working.
Topical Magnesium
Magnesium sprays and creams are widely marketed for muscle cramps, but the science on skin absorption is thin. The outer layer of skin lacks the transporter proteins that move magnesium into cells, so absorption happens only through tiny areas around sweat glands and hair follicles. One small human study found that applying 56 mg of magnesium cream daily for two weeks did not produce a statistically significant change in blood magnesium levels. Some people report subjective relief, which may come from the act of massaging the area rather than the magnesium itself. Topical products are safe to use, but oral supplements are a more reliable way to raise your magnesium levels.
B Vitamins
A vitamin B complex supplement is another option with modest evidence behind it. A study published in Neurology found that a B complex containing 30 mg of vitamin B6 per day induced remission of muscle cramps in 86% of treated patients compared to placebo, even in people who weren’t known to be vitamin deficient. The study was small (28 patients), and the American Academy of Neurology rates the recommendation as Level C, meaning it may be considered but isn’t strongly proven. Side effects were minor: occasional lightheadedness, nausea, and stomach discomfort at similar rates to the placebo group. A standard B-complex supplement from any pharmacy covers these doses.
Why Quinine Is Not an Option
Quinine used to be the go-to remedy for nighttime leg cramps, and some people still ask about it. The FDA shut this down with a boxed warning, its strongest safety alert. Quinine for leg cramps can cause life-threatening blood disorders, kidney damage, dangerous heart rhythm changes, and death. The FDA’s label states explicitly: “Quinine is NOT approved to prevent or treat nighttime leg cramps.” The agency concluded that because nocturnal leg cramps are a benign, self-limiting condition, the risks of quinine far outweigh any benefit. Tonic water contains trace amounts of quinine, but not enough to be therapeutic, and not enough to be dangerous either.
Prescription Options for Severe Cases
If stretching, hydration, and supplements haven’t helped after several weeks, a handful of prescription medications are sometimes tried off-label. These include certain calcium channel blockers, muscle relaxants, and nerve pain medications. The evidence for all of them is low quality, and no single drug is recommended as a routine treatment. These are typically reserved for people whose cramps are frequent, painful enough to regularly disrupt sleep, and resistant to everything else. Your doctor would weigh the side effects of each option against how much the cramps are affecting your quality of life.
When Leg Cramps Signal Something Else
Most nighttime leg cramps are harmless, but persistent cramping can occasionally point to an underlying issue. Peripheral artery disease causes leg pain that typically starts with walking and stops with rest, but in more severe cases it can wake you from sleep. The key difference: PAD pain tends to feel like an aching or tightness in the hips, thighs, or calves and is often worse in one leg. You might also notice that wounds on your feet heal slowly, or that one leg feels cooler to the touch than the other.
Restless legs syndrome is another condition people confuse with cramps. It causes an uncomfortable urge to move your legs rather than a sudden, painful muscle contraction. Thyroid disorders, kidney disease, and certain medications (especially diuretics and statins) can also increase cramp frequency. If your cramps are happening most nights, are unusually severe, or come with swelling, numbness, or skin changes, it’s worth getting checked to rule out these possibilities.