Stretching the affected muscle is the single most effective way to stop a nighttime leg cramp in progress, and a daily stretching habit is the best-supported strategy for preventing them. Most nocturnal leg cramps are harmless, lasting anywhere from a few seconds to several minutes, but they become more common with age and can seriously disrupt sleep. The good news: a combination of simple physical techniques, hydration, and habit changes can dramatically reduce how often they happen.
How to Stop a Cramp in Progress
When a cramp seizes your calf or foot in the middle of the night, your instinct is to tense up. Do the opposite. Flex the cramping muscle by pulling your toes toward your shin. If the cramp is in your calf, standing up and pressing your heel into the floor can force the muscle to lengthen. For a foot cramp, grab your toes and gently pull them back toward you.
Once the initial spasm eases, massage the area with firm pressure to help the muscle relax fully. Applying heat (a warm towel or heating pad) increases blood flow and loosens the tissue. Some people find ice helps if the muscle stays sore afterward. Walking around for a minute or two can also signal the muscle to reset. The soreness that lingers after a bad cramp is normal and can last into the next day.
Why Cramps Happen at Night
Nighttime leg cramps are involuntary contractions, most often in the calf, that strike during sleep or while lying still. They differ from restless legs syndrome, which causes an uncomfortable urge to move rather than a sudden, painful tightening. Several factors make nighttime the peak time for cramps: your muscles have accumulated fatigue from the day, you’ve gone hours without fluids, and the sustained position of your foot in bed (toes pointed slightly downward) can trigger a calf contraction.
Common contributors include dehydration, lack of physical activity, muscle fatigue from unusual exertion, and pregnancy. Certain medications are well-documented triggers. Diuretics (water pills), statins for cholesterol, blood pressure medications including angiotensin II receptor blockers, oral contraceptives, and drugs with stimulant effects (caffeine, pseudoephedrine, nicotine) all increase cramp risk. If your cramps started or worsened after beginning a new medication, that connection is worth exploring.
Underlying health conditions can also play a role. Kidney disease, diabetes-related nerve damage, thyroid disorders, anemia, peripheral artery disease, and cirrhosis are all associated with more frequent cramps. Alcohol withdrawal is another known trigger.
Daily Stretching to Prevent Cramps
A consistent stretching routine is the most reliable way to reduce cramp frequency over time. The key is duration: holding each stretch for at least 60 seconds produces better results than shorter holds, according to the UCSF Orthopaedic Institute’s lower body stretching protocol. Their recommendation is three sets of 60-second holds, done two to three times per day, every day.
The most important stretch targets the calf. Stand facing a wall with one foot forward and one back, keeping your back heel on the ground and your back knee straight. Lean into the wall until you feel a deep stretch in the back calf. Then repeat with a slight bend in the back knee to reach the deeper calf muscle (the soleus). Doing this routine before bed is particularly helpful, since it primes the muscles to stay relaxed through the night. Many people notice a reduction in cramp episodes within the first couple of weeks of daily stretching.
Does Magnesium Actually Help?
Magnesium is the most popular supplement recommendation for leg cramps, but the evidence is more complicated than the advice suggests. A large 2020 systematic review of 11 randomized controlled trials found no overall reduction in leg cramps from magnesium supplementation, whether the cramps were related to pregnancy, liver disease, or unknown causes. For cramps with no clear cause, the difference between magnesium and placebo at four weeks was not meaningful.
There is one notable exception. A 2021 trial of 184 adults aged 45 and older tested 226 mg of magnesium oxide daily for 60 days. At the end of the trial, the magnesium group dropped from about 5.4 cramps per week to 1.9, while the placebo group went from 6.4 to 3.7. Cramp duration also fell significantly in the magnesium group. The takeaway: magnesium may help, but only at doses taken consistently for at least two months. Short courses under 60 days have not shown benefit in clinical trials.
If you want to try magnesium, giving it a full eight weeks before judging whether it works is reasonable. Getting magnesium through food (nuts, seeds, leafy greens, whole grains) is another option that comes with no downside.
B Vitamins and Other Supplements
Vitamin B complex has some preliminary support. A small 12-week trial of 28 older adults found that daily B complex supplementation led to cramp remission in 86% of participants, compared with no improvement in the control group. That’s a striking result, but the study was small and had methodological limitations. The American Academy of Family Physicians rates the evidence for B vitamins as low quality but potentially promising for short-term improvement.
Calcium channel blockers (a class of blood pressure medication) have also shown modest benefit in small trials, but these are prescription drugs with their own side effects, not something to take specifically for cramps.
Why You Should Avoid Quinine
Quinine, found in tonic water and once widely prescribed for leg cramps, is not considered safe or effective for this purpose. The FDA has explicitly warned against using quinine for cramps. It carries risks of a dangerous drop in blood platelets, severe allergic reactions, and heart rhythm abnormalities. Fatalities and kidney failure requiring dialysis have been reported. Quinine is approved only for treating malaria. The small amount in tonic water is unlikely to help cramps, and drinking large quantities to get a therapeutic dose introduces real danger.
Hydration and Other Lifestyle Changes
Dehydration is one of the most common and most fixable cramp triggers. Your muscles need adequate fluid and electrolytes to contract and relax normally. Drinking enough water throughout the day, and having a glass before bed, can make a noticeable difference, especially if you exercise, sweat heavily, or take diuretics. Adding a pinch of salt to water or eating potassium-rich foods (bananas, potatoes, avocados) helps maintain electrolyte balance.
Other practical habits that reduce cramp frequency:
- Stay active during the day. Physical inactivity is a recognized trigger. Even moderate daily walking keeps leg muscles conditioned.
- Avoid prolonged standing or sitting. Both can fatigue muscles in ways that set up nighttime cramps.
- Wear supportive shoes. Poor foot mechanics can contribute to calf fatigue.
- Untuck your bedsheets. Tight sheets push your feet into a pointed position, which shortens the calf and invites cramping. Keeping sheets loose lets your feet rest in a neutral position.
When Cramps Signal Something Else
Occasional leg cramps are extremely common and rarely indicate a serious problem. But certain patterns deserve attention. Cramps that happen frequently (multiple times per week), come with visible leg swelling, or leave your leg feeling weak rather than just sore may point to an underlying condition like peripheral artery disease, nerve damage, or a metabolic disorder.
It’s also worth knowing that leg pain from a deep vein thrombosis (a blood clot) can feel like a cramp. The distinguishing features of a clot include persistent swelling in one leg, skin that looks red or purple, and a feeling of warmth in the affected area. A true cramp spasms intensely and then releases. A clot produces steady pain and swelling that doesn’t go away when you stretch. If your leg pain comes with these features, that warrants prompt medical evaluation.

