Why Are My Legs Cramping: Causes, Triggers & Relief

Leg cramps happen when a muscle involuntarily contracts and won’t relax, most often in the calf, foot, or thigh. About 30% of adults experience them at some point, and they become more common with age. The causes range from simple dehydration and overuse to underlying medical conditions, medications, and nerve problems. Most leg cramps are harmless, but understanding what triggers yours can help you prevent them.

What Happens Inside a Cramping Muscle

A leg cramp isn’t your muscle acting on its own. Current evidence points to the spinal cord as the source. When a muscle is fatigued or stressed, the signals traveling between the muscle and the spinal cord get thrown off balance. Specifically, the nerve fibers that normally tell a muscle to relax (from structures called Golgi tendon organs) become less active, while the fibers that tell a muscle to contract become overexcited. This imbalance triggers the motor nerve to fire rapidly, locking the muscle into a sustained, painful contraction.

This is why cramps tend to strike when a muscle is already shortened or tired. A calf cramp at night, for example, often happens because your foot is naturally pointed downward in bed, keeping the calf in a shortened position for hours.

The Most Common Triggers

Several everyday factors can set the stage for cramps:

  • Dehydration and electrolyte shifts. When you lose fluids through sweat, illness, or not drinking enough water, the balance of sodium, potassium, magnesium, and calcium in your body shifts. These minerals are essential for normal muscle contraction and relaxation. Even mild dehydration during hot weather or after exercise can be enough to trigger a cramp.
  • Overuse or sudden activity. Starting a new exercise routine, hiking longer than usual, or spending hours on your feet can fatigue muscles enough to disrupt normal nerve signaling. This is especially true if you skip warming up or stretching afterward.
  • Prolonged sitting or standing. Keeping muscles in one position for a long time, whether at a desk or on your feet all day, reduces blood flow and can set you up for cramps later.
  • Low mineral intake. Diets low in potassium (found in bananas, potatoes, and leafy greens), magnesium (nuts, seeds, whole grains), or calcium can contribute to more frequent cramping over time.

Why Night Cramps Are So Common

Nocturnal leg cramps are surprisingly widespread. A large representative study of U.S. adults found that about 24 to 25% report mild nighttime cramps (fewer than 15 nights per month), while 6% experience moderate to severe episodes, meaning cramps on 15 or more nights each month. Among adults over 80, roughly a third report at least occasional nighttime cramps.

Night cramps tend to hit the calves or the soles of the feet, often jolting you awake. They’re more common as you age partly because muscle mass naturally decreases, tendons shorten, and nerves become more excitable. Sleeping in a position that keeps the calf shortened, like pointing your toes under heavy blankets, adds to the risk. If you get frequent night cramps, sleeping with your feet in a neutral position or propped against a footboard can make a noticeable difference.

Medications That Cause Cramping

Several common medications list muscle cramps as a side effect. Diuretics (water pills) used for blood pressure are among the most frequent culprits because they increase fluid and mineral loss through urine, particularly potassium and magnesium. Statins, the widely prescribed cholesterol-lowering drugs, have a reputation for causing muscle problems, though the actual cramp risk is smaller than many people assume. A large analysis published by the American College of Cardiology found only a 0.2% greater incidence of cramps in people taking statins compared to a placebo. The probability that a statin is actually causing your muscle symptoms is less than 1 in 10.

Other medications linked to leg cramps include certain asthma inhalers, blood pressure drugs that aren’t diuretics, and hormonal treatments. If your cramps started or worsened after beginning a new medication, that timing is worth noting.

Leg Cramps During Pregnancy

Leg cramps are one of the most common complaints during the second and third trimesters. The exact mechanism isn’t fully understood, but several factors converge: blood volume increases dramatically, the growing uterus puts pressure on leg veins, and mineral demands shift as the baby develops. Some research suggests that lower calcium levels in the blood during pregnancy contribute to cramping, and magnesium supplements may help, though the evidence is mixed.

Pregnancy-related cramps most often strike at night and in the calves. Gentle stretching before bed, staying hydrated, and wearing supportive shoes during the day all help reduce their frequency.

Spinal and Nerve-Related Causes

Not all leg cramps come from the muscle itself. Spinal stenosis, a narrowing of the space around the spinal cord in the lower back, can cause pain or cramping in one or both legs. The telltale pattern is cramps that worsen when you stand for a long time or walk, and improve when you sit down or lean forward. This happens because leaning forward opens up space in the spinal canal, relieving pressure on the nerves.

Herniated discs can produce similar symptoms. When the soft inner material of a spinal disc leaks out, it can press on nerves that supply the legs, causing cramping, tingling, or shooting pain. These conditions become more common with age as bone spurs develop and discs lose their cushioning. If your cramps consistently follow this standing-and-walking pattern, or if they come with numbness or weakness, a spinal issue is worth investigating.

Peripheral neuropathy, often related to diabetes, can also increase cramp frequency by disrupting the nerve signals that control muscle contraction.

How to Stop a Cramp in Progress

When a cramp hits, the goal is to gently lengthen the locked muscle. For a calf cramp, flex your foot by pulling your toes toward your shin. You can do this by standing and pressing into the floor, or by grabbing your toes while seated and pulling them back. Hold the stretch for about 30 seconds, release, and repeat if the muscle is still tight. Walking slowly on the affected leg also helps the muscle relax.

Massaging the cramping muscle with your hands or a foam roller can speed relief. Some people find that applying a warm towel or heating pad to the area after the cramp passes eases the residual soreness that can linger for hours or even a day afterward.

Preventing Cramps Long Term

Regular calf stretching is one of the most effective preventive measures, especially for nighttime cramps. A simple wall stretch, where you lean into a wall with one leg behind you and the heel flat on the ground, held for 30 seconds and repeated ten times, twice a day, can significantly reduce cramp frequency over a few weeks.

Beyond stretching, staying well-hydrated throughout the day matters more than drinking a lot of water right before bed (which just wakes you up for other reasons). If you exercise heavily or sweat a lot, replacing electrolytes with a sports drink or foods rich in potassium and magnesium is more effective than water alone. Wearing shoes with good arch support, avoiding high heels for extended periods, and keeping blankets loose at the foot of your bed are small changes that add up.

When Cramps Signal Something Serious

Most leg cramps are benign, but certain symptoms alongside a cramp point to something that needs medical attention. A deep vein thrombosis (a blood clot in a leg vein) can feel like a cramp, particularly in the calf, but it comes with distinct warning signs: swelling in the affected leg, skin that turns red or purple, and a feeling of warmth in that specific area. Unlike a typical cramp, the pain from a DVT doesn’t resolve with stretching and tends to persist or worsen over hours.

Cramps that happen frequently despite adequate hydration and stretching, cramps accompanied by muscle weakness or visible wasting, and cramps that always occur in the same leg deserve a closer look. These patterns can point to nerve compression, circulation problems, or metabolic conditions that routine blood work and a physical exam can usually identify.