How to Prevent Leg Cramps at Night: What Works

Nighttime leg cramps can often be reduced or prevented with a combination of stretching, adjusting your sleep setup, staying hydrated, and in some cases, targeted supplements. Most nocturnal leg cramps have no single identifiable cause, which means prevention works best as a layered approach rather than a single fix.

Up to 60% of adults experience nocturnal leg cramps at some point, and they become more common with age as tendons naturally shorten. The cramps originate from overactive nerve signals in the lower motor neurons, firing involuntarily and causing the muscle to lock up. Understanding why they happen makes it easier to target the right prevention strategies.

Why Cramps Happen While You Sleep

When you lie in bed, your feet naturally point downward. This position shortens the calf muscles, and when they’re already contracted, even a small burst of involuntary nerve activity can trigger a full cramp. Muscle fatigue from the day’s activity adds to the risk. If you spent hours sitting at a desk, standing on hard floors, or did an unusually intense workout, your muscles are primed to misfire overnight.

Dehydration and low levels of key electrolytes (sodium, potassium, magnesium, calcium) also make muscles more excitable. These minerals regulate how nerve signals reach your muscles. When they’re depleted from sweating, not drinking enough water, or taking certain medications like diuretics, the threshold for a cramp drops significantly.

Stretch Your Calves Before Bed

A simple calf stretching routine before sleep is one of the most consistently recommended prevention strategies. The wall stretch works well: stand about arm’s length from a wall, place your hands on it, and step one foot back while keeping the heel flat on the floor. Hold for 30 seconds per leg and repeat two or three times. This lengthens the calf fibers that tend to shorten during sleep.

If you get a cramp during the night, the same principle applies in reverse. Flexing your foot upward (pulling your toes toward your shin) forces the cramping calf muscle to lengthen and usually breaks the spasm within seconds. Doing this stretch consistently before bed, not just when cramps strike, is what builds the preventive effect over time.

Fix Your Sleep Position and Bedding

Heavy blankets and tightly tucked sheets push your feet into a pointed position, keeping the calf muscles shortened for hours. Loosening the sheets at the foot of the bed, or using a lighter blanket, gives your feet room to stay in a neutral position. Some people find that sleeping on their back with a pillow propping the feet slightly upward, or sleeping on their stomach with feet hanging off the edge of the mattress, helps keep the calves from shortening overnight.

Stay Hydrated Throughout the Day

Dehydration doesn’t just mean you forgot to drink water at dinner. It’s cumulative. If you’re mildly dehydrated by afternoon, your electrolyte balance is already off by bedtime. Drinking fluids steadily throughout the day is more effective than loading up in the evening, which mostly just leads to bathroom trips. If you exercise or sweat heavily, replacing electrolytes (not just water) matters. A sports drink, coconut water, or even a pinch of salt in water can help maintain sodium and potassium levels.

What the Evidence Says About Supplements

Magnesium

Magnesium is the most commonly recommended supplement for leg cramps, but the evidence is mixed. A systematic review of 11 randomized trials found no overall reduction in leg cramps from magnesium. However, a more recent trial of 184 people taking 226 mg of magnesium oxide daily showed meaningful results after 60 days: cramp frequency dropped from about 5.4 episodes per week to 1.9, compared to a drop from 6.4 to 3.7 in the placebo group. The catch is that no benefit appeared at 30 days. If you try magnesium, give it at least two months before deciding whether it’s working.

For pregnant people, who frequently deal with leg cramps, the evidence is less encouraging. A meta-analysis of four trials found no significant difference between magnesium and placebo in that population.

Vitamin K2

A 2025 trial published by the AAFP found that vitamin K2 (specifically menaquinone-7) at 180 mcg taken in the evening cut the average number of weekly cramps roughly in half for adults 65 and older. Over two months, the treatment group had more than 21 fewer cramp episodes than the placebo group, and the difference showed up within the first week. This is a relatively new finding but comes from a well-designed, placebo-controlled trial.

B Vitamins

One small study found that a vitamin B complex supplement (including 30 mg of B6 daily) led to cramp remission in 86% of treated patients. The study was small, with only 28 participants, and the American Academy of Neurology rates B vitamins as only a “Level C” recommendation, meaning they may help but the evidence is limited.

Why You Should Avoid Quinine

Quinine, found in tonic water and sometimes prescribed off-label, was once a common cramp remedy. The FDA has explicitly stated it is not considered safe or effective for leg cramps. Quinine can cause life-threatening blood disorders, dangerous heart rhythm changes, and kidney failure requiring dialysis. Fatalities have been reported. Since 2006, the FDA has added boxed warnings and issued multiple safety communications about this risk. The small amount of quinine in a glass of tonic water is unlikely to cause harm, but it’s also unlikely to prevent cramps. Concentrated quinine tablets carry real danger and should not be used for this purpose.

When Cramps Point to Something Else

Most nighttime leg cramps are harmless, but frequent or severe cramps can signal an underlying condition. Chronic kidney disease, diabetes (both type 1 and type 2), and peripheral artery disease are all associated with nocturnal cramping. Diabetic nerve damage in particular can increase the abnormal nerve firing that triggers cramps. Peripheral artery disease narrows blood vessels in the legs, reducing blood flow to muscles.

If your cramps are new, happening most nights, or accompanied by leg swelling, numbness, or skin changes, those are signs the cramps may be a symptom rather than the whole problem. Low potassium (which can result from certain blood pressure medications) is another common culprit that a simple blood test can identify.

Putting a Prevention Routine Together

The most practical approach combines several low-risk strategies. Stretch your calves for a few minutes before bed each night. Keep your sheets loose at the foot of the bed. Drink water consistently during the day and replenish electrolytes if you’ve been sweating. If cramps persist after a few weeks of these habits, adding magnesium or vitamin K2 is reasonable, keeping in mind that supplements typically need at least a month to show effects. For people over 65, who are most affected by nocturnal cramps, the vitamin K2 data is particularly relevant given how quickly the benefits appeared in the trial.

Light activity during the day, like a short walk in the evening, can also help. The goal is to keep the calf muscles moving and lengthened rather than allowing them to sit in a shortened, fatigued state heading into sleep. Stationary cycling for a few minutes before bed serves the same purpose and is gentle enough not to add the kind of muscle fatigue that worsens cramping.