Nighttime foot cramps can usually be stopped in the moment by stretching the affected muscle, and prevented long-term with a few changes to your hydration, stretching habits, and sleep setup. Most nocturnal cramps have no identifiable medical cause. They’re generally the result of tired muscles and overactive nerves, and they tend to strike more often as you get older. The good news is that this is a manageable problem for most people.
How to Stop a Cramp in Progress
When a foot cramp hits at 2 a.m., your instinct is to curl up and wait it out. Do the opposite. Flex your foot by pulling your toes upward toward your shin. This lengthens the cramping muscle and forces it to release. If you can stand safely, press your foot flat against the floor and lean forward slightly, which achieves the same stretch with your body weight doing the work.
Walking around for a few minutes after the cramp releases helps restore normal blood flow and reduces the soreness that often lingers. Massaging the arch of your foot or the base of your toes with your thumbs can also help the muscle relax faster. Some people find that applying a warm towel or heating pad to the area eases the residual ache and helps them fall back asleep.
Why Your Feet Cramp at Night
During the day, your feet and calves are constantly making small adjustments as you stand and walk. At night, those muscles go still for hours, and the nerves that control them can misfire, triggering a sudden, involuntary contraction. Sleeping with your feet pointed downward (a position called plantarflexion) shortens the muscles along the sole of your foot, making them more prone to cramping.
Several factors raise your risk. Dehydration reduces the fluid available to your muscle cells. Electrolyte imbalances, particularly low levels of potassium, sodium, or calcium, disrupt the signals between your nerves and muscles. Muscle fatigue from a long day on your feet, a new exercise routine, or simply standing on hard surfaces can set the stage for cramps hours later when you’re in bed.
Certain medications are also known triggers. Diuretics (water pills), cholesterol-lowering statins, some antidepressants, sleep aids, and pain relievers like naproxen all list leg and foot cramps as potential side effects. If your cramps started around the same time as a new medication, that connection is worth raising with your prescriber.
Stretching to Prevent Cramps
A short stretching routine before bed is one of the most reliable ways to reduce how often you get nighttime cramps. Focus on three areas: the arch of your foot, your calf muscles, and your toes.
- Towel stretch: Sit on the floor with your legs straight. Loop a towel around the ball of one foot and gently pull the towel toward you, holding for 20 to 30 seconds. You should feel the stretch through your arch and calf.
- Wall calf stretch: Stand facing a wall with one foot forward and one back. Keep your back heel on the ground and lean into the wall until you feel a stretch in the back calf. Hold for 30 seconds per side.
- Toe curls and spreads: While sitting, curl your toes tightly for five seconds, then spread them as wide as you can for five seconds. Repeat ten times. This activates the small muscles in the foot that are most prone to cramping.
Doing these stretches nightly, even on cramp-free days, helps keep the muscles supple and less reactive to the nerve signals that trigger involuntary contractions.
Hydration and Electrolytes
Dehydration is one of the most common and fixable contributors to nighttime cramps. Your muscles need adequate fluid to contract and relax properly, and most people are mildly dehydrated by bedtime. Drinking water steadily throughout the day matters more than gulping a large amount before bed (which just means more bathroom trips).
Electrolytes matter too. Potassium supports nerve and muscle function, sodium controls fluid balance, and calcium helps muscles contract and relax in a coordinated way. When any of these dip too low, cramps become more likely. Potassium-rich foods like bananas, sweet potatoes, and avocados can help, along with adequate dietary calcium from dairy or leafy greens. If you sweat heavily during the day or exercise in the evening, a drink with electrolytes before bed can make a noticeable difference.
Adjusting Your Sleep Setup
Small changes to how you sleep can reduce foot cramps significantly. Tight sheets and heavy blankets push your feet into a pointed position, which shortens the foot muscles for hours at a time. Untucking the covers at the foot of your bed gives your feet room to stay in a neutral position.
Sleeping on your back or side with a pillow under your knees helps maintain better circulation to your lower legs. If you tend to sleep on your stomach, your feet naturally point downward into the mattress, which is the exact position most likely to trigger a cramp. Even switching to your side can make a difference. Some people also find that wearing loose, soft socks to bed keeps the foot muscles warm and less prone to sudden contractions.
Do Supplements Help?
Magnesium is the most commonly recommended supplement for nighttime cramps, but the evidence is mixed. A review by the American Academy of Family Physicians found that short courses of magnesium (under 60 days) do not reduce cramp frequency in most adults. One clinical trial showed some benefit after taking 226 mg of magnesium oxide daily for at least 60 days, but this was a single study. If you want to try magnesium, give it at least two months before judging whether it’s working.
Vitamin B complex has slightly stronger evidence behind it. A clinical study published in the journal Neurology found that a B-complex supplement (including 30 mg of vitamin B6 daily) led to cramp remission in 86% of treated patients who weren’t previously deficient. The study was small, with only 28 participants, but it reported no serious side effects. B-complex is classified as “possibly effective” for muscle cramps in evidence-based reviews.
One old remedy to avoid: quinine. Once widely used for leg cramps, quinine now carries a boxed warning from the FDA, the agency’s most serious safety label. It can cause life-threatening blood disorders, dangerous heart rhythm changes, kidney damage, and death. The FDA explicitly states that quinine is not approved for treating or preventing nighttime leg cramps, and the risks far outweigh any benefit for what is ultimately a non-dangerous condition. If someone suggests tonic water as a cramp remedy (tonic water contains small amounts of quinine), know that the dose is too low to help and the approach itself is based on a treatment that’s been deemed unsafe.
When Cramps Signal Something Else
Occasional foot cramps are normal, especially after active days or as you get older. But cramps that happen almost every night, come with numbness or tingling, or cause persistent weakness in your foot or leg can point to underlying conditions like peripheral neuropathy (nerve damage, often related to diabetes) or circulation problems in the legs. Cramps that don’t respond to stretching, hydration, and the other measures above are worth investigating further, particularly if they’ve worsened over weeks or months.

