Why Leg Cramps at Night: Causes and How to Stop Them

Nocturnal leg cramps happen when motor neurons in your spinal cord become hyperexcitable and fire involuntarily, locking a muscle into a sustained, painful contraction. Up to 33% of adults over 50 experience them, with the highest rates in people aged 60 to 69. They’re one of the most common sleep disruptions, and while they’re rarely dangerous, the pain can be intense enough to wake you from deep sleep and leave the muscle sore for hours afterward.

What Happens Inside the Muscle

A leg cramp isn’t just a tight muscle. It’s a feedback loop gone wrong. Normally, nerve signals tell a muscle to contract and then relax in a controlled sequence. During a cramp, motor neurons develop what researchers call “persistent inward currents,” essentially getting stuck in the “on” position. The muscle contracts, that contraction sends signals back to the spinal cord, and those signals further excite the motor neurons, which fire even harder. This self-sustaining loop is why a cramp can persist for seconds or minutes even though you never told the muscle to tighten in the first place.

The calf is the most common target because it contains large muscles controlled by long motor neurons that are particularly susceptible to this kind of runaway signaling. Your foot and thigh can cramp too, but the calf’s anatomy makes it the usual victim.

Why They Happen at Night Specifically

Several things converge while you sleep that make cramps more likely. When you’re lying still for hours, blood flow to your legs slows and your muscles stay in shortened positions, especially if you sleep with your feet pointed downward. That foot position keeps the calf muscle slightly contracted for long stretches, which may prime the motor neurons to misfire. You’re also mildly dehydrated by the middle of the night since you haven’t had water in hours, and your body’s electrolyte balance shifts slightly as fluid redistributes while you’re horizontal.

There’s no single trigger. It’s usually the combination of prolonged stillness, subtle dehydration, and muscle positioning that tips the nervous system into that feedback loop.

Common Risk Factors and Causes

Age is the strongest predictor. As you get older, you lose muscle mass, and the remaining muscle fatigues more easily. Tendons shorten over time, which changes resting muscle tension. These structural changes make the motor neuron feedback loop easier to trigger.

Beyond aging, several other factors raise your risk:

  • Dehydration and electrolyte dilution. Drinking plain water after sweating heavily can actually make cramps more likely, not less. Research shows that replacing lost fluids without also replacing sodium and other electrolytes dilutes the minerals in your blood and extracellular fluid. Low sodium in particular increases muscle cramp susceptibility. This is why sports drinks exist, and why people who exercise heavily or work outdoors are prone to cramps later that night.
  • Pregnancy. Leg cramps are common during the second and third trimesters, often striking at night. The exact mechanism isn’t fully understood, but lower blood calcium levels during pregnancy likely play a role, along with increased weight on the legs and changes in circulation.
  • Prolonged sitting or standing. Jobs that keep you in one position for hours can fatigue leg muscles without you noticing, setting the stage for cramps once you finally lie down.
  • Exercise patterns. Both too much and too little physical activity increase cramp risk. Overworking a muscle creates fatigue that makes motor neurons more excitable. Being sedentary leads to gradual muscle shortening and poor circulation.

Medications That Can Trigger Cramps

Certain prescription drugs significantly increase the likelihood of nocturnal leg cramps. A large study published in JAMA Internal Medicine found three drug classes with the strongest links.

Inhaled long-acting bronchodilators, the type used in asthma and COPD inhalers, carried the highest risk. People were roughly 2.4 times more likely to need cramp treatment after starting these medications, with combination inhalers (bronchodilator plus corticosteroid) showing a slightly higher association than the bronchodilator alone.

Diuretics, commonly prescribed for high blood pressure and fluid retention, were the second most common culprit. Potassium-sparing diuretics doubled cramp risk, while thiazide-type diuretics increased it by about 48%. This makes physiological sense: diuretics change your body’s fluid and electrolyte balance, which directly affects muscle excitability. Loop diuretics showed a weaker and less certain link.

Statins, used to lower cholesterol, had a smaller but statistically significant association, raising cramp likelihood by about 16%. Over a 13-year study period, roughly 60% of people being treated for cramps were also taking at least one of these three medication types. If your night cramps started or worsened after beginning a new medication, that connection is worth discussing with your prescriber.

Underlying Health Conditions

Most nocturnal leg cramps are idiopathic, meaning they happen without an identifiable disease behind them. But persistent, frequent cramps can sometimes signal an underlying condition. Peripheral artery disease narrows blood vessels in the legs, reducing oxygen delivery to muscles. Chronic kidney disease and liver cirrhosis both disrupt electrolyte regulation. Diabetes can damage peripheral nerves in ways that make motor neurons more prone to misfiring. Thyroid disorders, both overactive and underactive, alter muscle metabolism.

If your cramps are happening multiple times per week, getting worse over time, or accompanied by muscle weakness, numbness, or swelling, those patterns suggest something beyond ordinary nighttime cramping.

Cramps vs. Restless Legs Syndrome

These two conditions often get confused because they both strike the legs at night, but they feel completely different. A cramp is a sudden, painful contraction you can usually see and feel as a hard knot in the muscle. It forces the muscle into a locked position. Restless legs syndrome, by contrast, involves an uncomfortable urge to move your legs, often described as crawling, tingling, or aching. Moving your legs relieves restless legs syndrome but does nothing for a cramp. In fact, during a cramp, your muscle is already contracting involuntarily. The two conditions require different approaches, so being clear about which one you’re experiencing matters.

What Actually Helps

When a cramp hits, the most effective immediate response is to stretch the cramping muscle by pulling your toes toward your shin (for a calf cramp) or straightening your leg. This counteracts the contraction and can help interrupt the motor neuron feedback loop. Walking on the affected leg also works because it forces the muscle into a lengthened position. Some people find that massaging the muscle or applying heat afterward helps with the residual soreness.

Stretching for Prevention

Calf stretches before bed are the most commonly recommended preventive measure, though the evidence is weaker than you might expect. A randomized controlled trial published in the British Journal of General Practice tested a daily calf-stretching program and found it did not significantly reduce the frequency or severity of nocturnal leg cramps compared to placebo exercises. That said, stretching carries no risk and many clinicians still suggest it. If you try it, the typical approach is standing arm’s length from a wall, leaning forward with your back leg straight and heel on the floor, holding for 30 seconds per side.

Magnesium Supplements

Magnesium is perhaps the most popular home remedy for leg cramps, but the clinical evidence is disappointing for most people. A randomized trial giving 520 mg of elemental magnesium daily for four weeks found no meaningful difference compared to placebo in cramp frequency, severity, duration, sleep quality, or quality of life. Both groups improved, suggesting a strong placebo effect. The one exception may be pregnancy: some research supports magnesium supplementation for pregnant women experiencing cramps, though the evidence is mixed even there.

Hydration and Electrolytes

Staying well hydrated matters, but how you hydrate matters more. Drinking large amounts of plain water, especially after sweating, can dilute sodium and chloride levels in your blood and actually make muscles more cramp-prone. If you suspect dehydration is contributing to your cramps, adding electrolytes to your water or eating mineral-rich foods in the evening may be more effective than water alone.

Quinine: Effective but Dangerous

Quinine, found in tonic water at low doses and in prescription tablets at higher ones, does reduce cramp frequency for some people. But the FDA has issued explicit warnings against using it for leg cramps. It is approved only for treating malaria. When used for cramps, quinine carries risks of serious blood disorders, including conditions where the body destroys its own platelets, potentially leading to kidney failure requiring dialysis. Fatal reactions have been reported. The FDA added a boxed warning, the most serious type, specifically about using quinine off-label for cramps. The small benefit is not worth the risk for a condition that, while painful, is not life-threatening.

Practical Steps to Reduce Nighttime Cramps

Since no single intervention has strong evidence on its own, most people benefit from addressing multiple contributing factors at once. Keep your calves warm at night, as cold muscles cramp more easily. Sleep with loose blankets that don’t push your feet into a pointed position, or use a pillow or footboard to keep your feet upright. Stay active during the day to maintain muscle mass and circulation, but avoid intense exercise close to bedtime. If you take diuretics, inhalers, or statins, pay attention to whether your cramps correlate with when you started or changed doses. And focus on electrolyte-balanced hydration rather than water alone, especially if you’re active, pregnant, or taking medications that affect fluid balance.