Nighttime leg cramps can often be prevented with a combination of daily calf stretching, proper hydration, and small changes to how you sleep. About 6% of U.S. adults experience frequent nocturnal leg cramps, and the rate climbs with age, affecting roughly 8% of people in their 60s and over 11% of those 80 and older. The good news is that most prevention strategies are simple and free.
Why Leg Cramps Happen at Night
The exact mechanism behind nocturnal leg cramps isn’t fully understood, but the leading theory points to overactive nerve signals. Electrical studies of cramping muscles show that the lower motor neurons fire rapidly and involuntarily, locking the muscle into a sustained contraction. Several factors make this more likely to happen while you’re in bed.
When you lie down, your foot naturally points downward. In that position, your calf muscle is already in its most shortened state. With the muscle fibers compressed and no movement to keep nerve signaling in check, it takes very little extra stimulation for a cramp to fire. Muscle fatigue from the day’s activity compounds the problem. Studies of endurance athletes confirm that higher-than-usual exercise intensity is strongly associated with cramping, and the same principle applies on a smaller scale to anyone who was more active than normal during the day.
One hypothesis suggests that modern life itself plays a role. Humans historically spent significant time in deep squatting positions that kept calf muscles and tendons stretched. Without that regular lengthening, the muscles may become more prone to involuntary contraction.
Stretch Your Calves Daily
The single most effective self-care strategy is a regular calf stretching routine. The NHS recommends a simple approach: stand facing a wall, place one foot behind you with the heel flat on the floor, and lean forward until you feel a stretch in the back calf. Hold for two to three seconds, then release. Repeat for about five minutes, three times per day, with the last session right before bed.
If your cramps become less frequent, you can scale back to once or twice a day. The key is consistency. Stretching works by keeping the calf muscle fibers at a longer resting length, which makes them less likely to fire into a cramp when you’re lying still. Many people notice improvement within a few weeks.
Adjust Your Sleeping Setup
A surprisingly simple fix is loosening the covers at the foot of your bed. Tight sheets and heavy blankets push your feet into a pointed position, shortening the calf muscles for hours at a time. Untucking the bottom of your bedding lets your feet rest in a more neutral angle. If you sleep on your back, placing a pillow at the foot of the bed to prop your feet against can help keep them from dropping forward.
Stay Hydrated and Mind Your Electrolytes
Muscles depend on a precise balance of sodium, potassium, magnesium, and calcium to contract and relax properly. When any of these minerals run low, the “off switch” for muscle contraction can fail, and the muscle locks into spasm instead of releasing smoothly. Nocturnal cramps may be linked to inadequate replacement of electrolytes lost throughout the day, especially if you’ve been sweating, exercising, or not drinking enough water.
Low potassium disrupts the signals that tell muscles when to contract and relax. Low magnesium makes muscles more excitable and quicker to cramp. Low sodium throws off fluid balance, and low calcium affects the nerve firing that controls smooth contraction. Drinking water steadily throughout the day and eating potassium-rich foods like bananas, potatoes, and leafy greens is a reasonable starting point. If you exercise heavily or sweat a lot, a drink with electrolytes can help replace what you’ve lost.
What About Magnesium Supplements?
Magnesium is the supplement most commonly recommended for leg cramps, but the clinical evidence for non-pregnant adults is weak. A systematic review published in the Drug and Therapeutics Bulletin concluded that magnesium supplementation is unlikely to provide meaningful cramp prevention in older adults. That doesn’t mean it never helps, particularly if you’re genuinely deficient, but taking magnesium pills isn’t the reliable fix many people expect.
Vitamin B complex has slightly more promising, though limited, data. A 12-week trial of 28 older adults found that daily B-complex supplementation led to cramp remission in 86% of treated patients, compared with no improvement in the control group. The study was small, and results haven’t been widely replicated, but it suggests B vitamins may be worth trying if cramps persist despite other measures.
Check Your Medications
Several common medications can trigger or worsen leg cramps. Statins (cholesterol-lowering drugs) cause muscle pain and cramping in 15% to 20% of patients, with women affected more often than men. Diuretics (water pills) deplete electrolytes, which directly increases cramp risk. If you take either of these and started getting cramps around the same time, it’s worth bringing up with your prescriber. Sometimes a dosage adjustment or a switch to a different medication can make a significant difference.
Low vitamin D levels also increase the risk of statin-related muscle problems. If you’re on a statin and experiencing cramps, having your vitamin D checked and correcting any deficiency may help reduce symptoms.
Avoid Quinine
Quinine, found in tonic water and once prescribed specifically for leg cramps, is not considered safe or effective for this purpose. The FDA has issued multiple warnings about serious risks, including a dangerous drop in blood platelets, life-threatening allergic reactions, and heart rhythm disturbances. Fatalities and kidney failure requiring dialysis have been reported. Since 2006, the FDA has added a boxed warning to quinine labeling and repeatedly warned healthcare providers against prescribing it for cramps. Quinine is approved only for treating malaria.
What to Do When a Cramp Strikes
When a cramp hits mid-sleep, the fastest relief comes from stretching the locked muscle. For a calf cramp, flex your foot upward by pulling your toes toward your shin. You can grab your toes with your hand or press your foot against the headboard or wall. This forces the cramping muscle to lengthen, which interrupts the involuntary contraction. Walking on the affected leg for a minute or two can also help the muscle release. Gentle massage and applying warmth afterward can ease any lingering soreness.
If cramps are happening several times a week despite consistent stretching, hydration, and bedding adjustments, the pattern may point to an underlying issue like nerve irritation, circulation problems, or an electrolyte imbalance that blood work can identify.

