When a nighttime leg cramp strikes, the fastest way to stop it is to flex your foot upward, pulling your toes toward your shin. This forceful stretch of the calf muscle can interrupt the cramp within seconds. Beyond that immediate fix, several practical changes to hydration, stretching habits, and sleep setup can reduce how often cramps wake you up.
How to Stop a Cramp in Progress
The moment you feel that sudden tightening in your calf or foot, dorsiflex the affected muscle. That means pulling your toes up toward your knee, which forces the cramping muscle to lengthen. If the cramp is in your calf, you can also stand up and press your feet flat against the floor, putting your body weight into the stretch. Walking around and gently wiggling the leg helps the muscle release further.
Once the acute spasm fades, follow up with either heat or cold. A heating pad or warm towel on the area relaxes the muscle fibers and eases residual soreness. Some people prefer wrapping a bag of ice in a towel and applying it instead. Either approach works. Over-the-counter pain relievers like ibuprofen or acetaminophen can help with the lingering ache that sometimes persists into the next morning. After the cramp subsides, propping your leg up on a pillow can reduce any remaining tightness.
Stretching Before Bed
A nightly calf stretch is the single most commonly recommended prevention strategy. Stand facing a wall with one foot forward, bend the front knee, and keep the back leg straight with the heel pressed into the floor. Hold for 20 to 30 seconds, then switch sides. Doing this right before bed targets the muscles most likely to cramp overnight.
A few minutes of light exercise in the evening, like pedaling on a stationary bike or walking on a treadmill, also appears to reduce cramp frequency. The idea is that gentle, rhythmic movement keeps the calf and foot muscles from shortening into the contracted position they tend to drift toward during sleep. If your cramps are partly related to muscle fatigue from daytime activity, gradually building fitness through graded exercise can help over time.
Electrolytes Matter More Than Water Alone
The common advice to “just drink more water” is incomplete and possibly counterproductive. Research from Edith Cowan University found that drinking plain water before and after exercise actually made muscles more prone to cramping, because it dilutes the body’s electrolyte concentration. People who drank electrolyte-containing fluids instead became more resistant to cramps. The electrical threshold needed to trigger a cramp went up with electrolyte water and went down with plain water.
Electrolytes, including sodium, potassium, magnesium, and chloride, are essential for normal muscle contraction and relaxation. If you sweat heavily during the day, exercise regularly, or take medications that increase fluid loss, replacing those minerals matters. You can do this through electrolyte drinks, or by eating potassium-rich foods like bananas and potatoes, calcium-rich foods like dairy, and magnesium-rich foods like nuts and leafy greens. The key point: staying hydrated is important, but hydrating with electrolytes is what actually protects against cramps.
Does Magnesium Supplementation Help?
Despite its popularity, magnesium supplements have weak evidence for preventing nighttime leg cramps in most people. A 2020 systematic review of 11 randomized controlled trials involving 735 patients found no meaningful reduction in cramp frequency when comparing magnesium to placebo. Across five studies, magnesium reduced cramps by less than one-fifth of a cramp per week, a difference that was not statistically significant.
There is limited evidence that magnesium oxide taken for longer than 60 days may eventually help, based on a single trial. But for courses shorter than two months, the American Academy of Family Physicians recommends against using magnesium supplements for nighttime cramps. If you’re already taking magnesium and feel it helps, it’s generally safe. Just don’t expect dramatic results based on what the clinical data shows.
Vitamin B Complex: Limited but Possible Benefit
One small but notable study found that a vitamin B complex supplement (including 30 mg per day of vitamin B6) led to remission of muscle cramps in 86% of treated patients compared to placebo. These were people with no known vitamin deficiency. The American Academy of Neurology considers vitamin B complex “possibly effective” for muscle cramps, though this rating is based on a single study of just 28 patients. No serious side effects were reported. It’s a low-risk option worth discussing if stretching and electrolyte changes haven’t been enough.
Foot Position During Sleep
When you sleep with your feet pointed downward, a position called plantar flexion, your calf muscles stay in a shortened state for hours. This makes them more likely to fire involuntarily and cramp. Sleeping on your back with heavy blankets pressing your feet down is a common setup for this problem.
To counteract this, try loosening the sheets at the foot of the bed so your feet aren’t pushed into a pointed position. Sleeping on your side with a pillow between your knees can also keep your feet in a more neutral alignment. Some people find that wearing supportive, well-fitted shoes during the day reduces nighttime cramping as well, likely because proper arch support reduces the cumulative muscle fatigue that makes cramps more likely after you fall asleep.
Medications That Trigger Cramps
Several common medications can increase your risk of nighttime leg cramps. Diuretics (water pills) are among the most frequent culprits because they increase the excretion of potassium, magnesium, and other electrolytes. Statins, used for cholesterol management, are well known for causing muscle-related side effects including cramps. Other medications linked to leg cramps include certain blood pressure drugs, asthma inhalers containing beta-agonists, and hormone therapies like estrogen.
If your cramps started or worsened after beginning a new medication, that timing is worth noting. Your prescriber may be able to adjust the dose or switch to an alternative.
Why Quinine Is No Longer Recommended
Quinine was once widely prescribed for leg cramps, and some people still seek it out in tonic water or through leftover prescriptions. The FDA has taken a firm stance against this use. Quinine is approved only for treating malaria and carries serious risks when used for cramps, including a dangerous drop in platelet count, life-threatening allergic reactions, and heart rhythm abnormalities. Fatalities and kidney failure requiring dialysis have been reported. Since 2006, the FDA has issued multiple warnings, added a boxed warning to quinine labeling, and made it clear that this drug is not considered safe or effective for leg cramps.
Medical Conditions Linked to Night Cramps
Most nighttime leg cramps are idiopathic, meaning there’s no identifiable underlying disease. But persistent, frequent, or worsening cramps can sometimes signal a medical condition. Kidney disease, diabetic nerve damage, and poor circulation from peripheral artery disease are known causes. Thyroid disorders (both overactive and underactive), anemia, and liver cirrhosis are also associated with increased cramping. Neurological conditions like Parkinson’s disease, peripheral neuropathy, and spinal stenosis can contribute as well.
Cramps that are increasing in severity over time, that don’t respond to stretching or massage, that come with visible swelling or skin color changes in the leg, or that limit your ability to walk or function during the day are worth bringing to a doctor. The same goes for cramps accompanied by muscle wasting, numbness, or pain that spreads to your back or arms. These patterns suggest something beyond ordinary muscle spasms and benefit from evaluation.

