How to Get Rid of Night Leg Cramps: Relief & Prevention

Night leg cramps can often be stopped mid-spasm and prevented long-term with a combination of stretching, hydration, and simple changes to your sleep setup. Most episodes hit the calf or foot, last a few seconds to several minutes, and leave behind a sore muscle that can ache into the next day. The good news is that the majority of nocturnal cramps respond well to self-care strategies you can start tonight.

How to Stop a Cramp That’s Already Happening

When a cramp fires in the middle of the night, your goal is to lengthen the contracting muscle as quickly as possible. For a calf cramp, the most effective move is to flex your foot upward, pulling your toes toward your shin. You can do this by grabbing your toes and pulling, or by standing up and pressing the ball of your foot into the floor while leaning forward slightly. If the cramp is in the front of your thigh, pull your foot behind you toward your glutes to stretch the muscle in the opposite direction.

Walking around for a minute or two after the initial spasm releases can help the muscle fully relax. Some people find that applying a warm towel or heating pad to the cramped area speeds relief, while others prefer a brief massage with firm pressure along the length of the muscle. Ice can help with the residual soreness afterward, but heat tends to work better during the active cramp because it promotes blood flow and relaxes the fibers.

Stretching Before Bed

A short stretching routine before sleep is one of the most reliable ways to reduce how often cramps happen. Aim for about 10 minutes of gentle stretching, ideally 30 minutes to an hour before you get into bed. Focus on the muscles that cramp most: calves, hamstrings, and quads.

For your calves, stand facing a wall with one foot stepped back, heel flat on the floor, and lean forward until you feel the stretch in the back of your lower leg. Hold for 30 seconds, repeat three times, then switch sides. For your hamstrings, lie on your back and raise one leg toward the ceiling (using a towel looped around your foot if needed), hold for 30 seconds, and repeat three times per leg. For your quads, stand on one leg and pull the opposite foot up behind you toward your glutes, hold 30 seconds, three times per side. These three stretches, done consistently each night, target the exact muscles most prone to nocturnal cramping.

Hydration and Electrolytes

Dehydration makes muscles more excitable and prone to involuntary contraction. Drinking fluids steadily throughout the day, rather than trying to catch up at night, is the most practical approach. If you exercise, sweat heavily, or take medications that increase fluid loss (like diuretics), you need more than the average person.

Plain water helps, but electrolyte balance matters just as much as total fluid volume. Research on exercise-related cramps has found that oral rehydration solutions, which contain sodium and potassium, are more effective at reducing cramping than water alone. You don’t necessarily need a special drink. Low-sugar sports drinks, low-fat milk, bananas, spinach, and yogurt all supply the key electrolytes (potassium, magnesium, sodium, calcium) that keep muscle signaling stable. Foods with high water content, like cucumbers, strawberries, tomatoes, and soups, contribute to both hydration and mineral intake. Caffeine and alcohol both promote fluid loss, so moderating them, especially in the evening, can help.

Supplements That May Help

Magnesium is the supplement most commonly recommended for leg cramps, but the clinical evidence is disappointing. A randomized trial of magnesium oxide for nocturnal leg cramps was terminated early because an interim analysis showed it was not working better than placebo. That doesn’t mean magnesium is useless for everyone, particularly if you’re low on it, but it’s not the reliable fix many people expect.

Vitamin B complex has slightly more promising data. A small clinical study found that a B-complex supplement (containing 30 mg of vitamin B6 per day) led to remission of muscle cramps in 86% of treated patients compared to placebo. Side effects were minimal and no different from the placebo group. That said, this was a single small study, and the evidence is considered preliminary.

The newest and most compelling finding involves vitamin K2. A randomized trial found that taking 180 micrograms of menaquinone-7 (a form of vitamin K2) in the evening for two months cut the average number of cramps per week roughly in half, dropping from about two per week down to less than one, while the placebo group’s cramps actually increased. Over the two-month study, the vitamin K2 group experienced more than 21 fewer cramp episodes. Vitamin K2 has few side effects, but it interferes with warfarin (a blood thinner), so it’s not appropriate for everyone.

Your Sleep Position and Foot Placement

The position of your feet during sleep plays an underappreciated role. When you sleep on your stomach or with heavy blankets pressing your feet downward, your calves stay in a shortened position for hours. That sustained shortening can trigger a cramp. Sleeping on your back with your toes pointing upward, or on your side with your feet in a neutral position, keeps the calf muscles longer and less likely to spasm. Loosening the sheets at the foot of the bed, or using a footboard or pillow to keep blankets off your feet, gives your ankles freedom to stay in a relaxed position.

Medications That Cause Night Cramps

If your cramps started or worsened after beginning a new medication, the drug itself may be the trigger. Several common medication categories are known to cause leg cramps as a side effect:

  • Diuretics (water pills used for blood pressure or swelling)
  • Statins (cholesterol-lowering drugs)
  • Certain antidepressants such as sertraline and fluoxetine
  • Hormone therapies including conjugated estrogens
  • Sleep medications like zolpidem
  • Pain relievers such as naproxen and celecoxib
  • Nerve pain medications including gabapentin and pregabalin

Diuretics deserve special attention because they deplete potassium and other electrolytes, directly increasing cramp risk. If you suspect a medication connection, bring it up with your prescriber. Sometimes a dose adjustment or switch to a different drug in the same class resolves the problem.

Medical Conditions Linked to Frequent Cramps

Occasional night cramps are extremely common and usually harmless. But frequent, severe cramps that don’t respond to the strategies above can signal an underlying condition. A study of outpatient veterans found cramps in 75% of those with peripheral vascular disease, 63% of those with low potassium levels, and 62% of those with coronary artery disease. About 60% of people with liver cirrhosis experience leg cramps, and 82% of cancer patients undergoing treatment in one small study reported them.

The full list of conditions associated with increased cramp frequency includes peripheral vascular disease, venous insufficiency, peripheral neuropathy, spinal stenosis in the lower back, kidney disease requiring dialysis, cirrhosis, pregnancy, osteoarthritis, cardiovascular disease, and neurological conditions like Parkinson’s disease. Cramps tied to these conditions tend to be more frequent, more intense, and less responsive to simple stretching and hydration. If your cramps are happening multiple times per week, worsening over time, or accompanied by leg swelling, numbness, weakness, or skin color changes, those are signs that something beyond ordinary muscle cramping may be going on.