Why Do My Feet and Legs Cramp at Night?

Nighttime leg and foot cramps happen when nerves in your lower legs fire spontaneously, causing muscles to lock into a painful, involuntary contraction. They most commonly strike the calf, the arch of the foot, or the thigh, and they tend to get more frequent with age. Most cases have no identifiable underlying disease, but several factors, from sleeping position to medications, can raise your risk.

What Happens Inside the Muscle

Electrical studies show that nocturnal cramps originate in the lower motor neurons, the nerve cells that directly control muscle fibers. These neurons begin firing at abnormally high frequencies without any signal from your brain, forcing the muscle into a sustained contraction that can last from a few seconds to several minutes.

One leading explanation involves foot position during sleep. When you lie in bed, your feet naturally point downward, a position that shortens the calf muscle as much as it can go. With the muscle already fully shortened, even a small burst of nerve activity can trigger a full cramp because the fibers have no slack to absorb the contraction. This is why cramps so often hit the calf and the arch of the foot rather than, say, your quadriceps.

Another theory points to modern lifestyles. Historically, humans spent significant time squatting, which deeply stretches the calves and Achilles tendons. Sitting in chairs all day leaves those muscles and tendons chronically shortened, making them more prone to involuntary contractions at night.

Common Risk Factors

For most people, nighttime cramps are “idiopathic,” meaning no single cause can be pinpointed. But several things increase the likelihood:

  • Age. Tendons naturally shorten as you get older, and motor nerve excitability tends to increase.
  • Prolonged standing or sitting. Spending long hours in one position during the day can leave muscles fatigued and more cramp-prone at night.
  • Dehydration and electrolyte shifts. Low fluid intake, heavy sweating, or imbalances in minerals like potassium, calcium, or magnesium can lower the threshold for nerve misfiring.
  • Medications. Several common drugs are associated with leg cramps. Inhaler medications containing albuterol, certain anti-inflammatory painkillers like naproxen, and hormone therapies including conjugated estrogens are among those most frequently linked. Some antidepressants, allergy medications, and antibiotics carry a smaller risk.
  • Pregnancy. Cramps are especially common during the second and third trimesters. Lower blood calcium levels during pregnancy may play a role, though the exact mechanism is still unclear.

Conditions like peripheral artery disease (reduced blood flow in the legs), diabetes, and liver disease have also been associated with more frequent cramping, though the cramps in those cases are typically one symptom among several.

Cramps vs. Restless Legs Syndrome

These two conditions are easy to confuse because both show up at night and both involve the legs. But they feel distinctly different. A nocturnal cramp is a sudden, intense, often agonizing tightening of a specific muscle. You can usually feel the knotted muscle with your hand, and the pain can linger as soreness even after the cramp releases.

Restless legs syndrome, by contrast, is not typically painful. It produces an uncomfortable crawling or pulling sensation deep in the legs, along with an overwhelming urge to move them. Moving relieves restless legs almost immediately, while moving during a cramp can initially make the pain worse until the contraction releases. If your nighttime leg discomfort is more “uncomfortable and fidgety” than “sharp and seized up,” restless legs syndrome is the more likely explanation.

Does Magnesium Actually Help?

Magnesium supplements are one of the most commonly recommended remedies for leg cramps, but the clinical evidence is surprisingly weak. A 2020 systematic review pooling 11 randomized controlled trials with 735 participants found no meaningful reduction in cramp frequency compared to placebo. Among the studies focused specifically on cramps with no known cause, magnesium reduced weekly cramp counts by less than one-fifth of a cramp per week over four weeks, a difference that was not statistically significant.

Based on this evidence, the American Academy of Family Physicians concluded that short courses of magnesium (under 60 days) should not be used to treat nighttime leg cramps, whether in the general population or during pregnancy. That said, if you are genuinely low in magnesium from diet or other reasons, correcting that deficiency is still worthwhile for overall health. It just may not fix your cramps.

Why Quinine Is Not Worth the Risk

Quinine, once widely prescribed for leg cramps, is approved only for treating malaria. The FDA has issued repeated warnings against using it for cramps because of serious, sometimes fatal side effects. These include a dangerous drop in platelet counts that can lead to uncontrolled bleeding, severe allergic reactions, and heart rhythm abnormalities. Deaths and kidney failure requiring dialysis have been reported. If a provider suggests quinine for your cramps, it is worth asking about alternatives.

What Actually Helps

The most reliable strategies are mechanical, not pharmaceutical. Stretching your calves and feet before bed is the single most consistently recommended intervention. A simple wall stretch works well: stand at arm’s length from a wall, press your palms against it, and step one foot back while keeping the heel on the ground. Hold for 30 seconds on each side. Doing this nightly can reduce both the frequency and severity of cramps over time.

During a cramp, the fastest relief comes from actively pulling your toes toward your shin, which forces the cramping muscle to lengthen. If the cramp is in your foot, standing and pressing your weight through the affected foot can accomplish the same thing. Massaging the knotted muscle and applying warmth afterward can ease the residual soreness that sometimes lasts into the next day.

A few other adjustments can lower your risk:

  • Keep sheets loose. Tightly tucked blankets push your feet into the pointed-down position that shortens calf muscles.
  • Stay hydrated. Drink enough water during the day, especially if you exercise or work in heat.
  • Wear supportive shoes. If you stand for long periods, proper arch support reduces the fatigue that contributes to nighttime cramping.
  • Move during the day. Even short walks help maintain circulation and keep tendons from stiffening.

If your cramps are happening multiple times a week, leave you unable to sleep, or come with new muscle weakness, swelling, or numbness, those patterns suggest something beyond the garden-variety nighttime cramp and are worth bringing up with a healthcare provider.