What Causes Cramps in Your Legs and How to Stop Them

Leg cramps are sudden, involuntary contractions of one or more muscles, most often in the calf. They have several possible causes, ranging from how you use your muscles during the day to underlying medical conditions. Roughly 50 to 60 percent of adults experience nocturnal leg cramps at some point, making them one of the most common muscle complaints.

Muscle Fatigue and Nerve Misfiring

The most widely supported explanation for exercise-related cramps centers on your nervous system, not your muscles themselves. During prolonged or intense activity, the nerve signals that tell a muscle to contract can become overactive while the signals that tell it to relax become underactive. This imbalance in nerve firing leads to a sustained, involuntary contraction. It’s especially likely to happen when a muscle is already in a shortened position, which is one reason calf cramps strike so often: the calf naturally shortens when you point your toes.

This same mechanism helps explain why cramps tend to hit late in a workout or race, when muscles are fatigued. Fatigue appears to be the primary trigger, not dehydration or salt loss on their own.

Why Cramps Happen at Night

Nighttime leg cramps are extremely common yet poorly understood. Most cases have no identifiable cause. One leading theory is positional: when you lie in bed, your foot naturally points downward, putting your calf muscles in a fully shortened state. In that position, even a small burst of nerve activity can set off a full cramp.

Another theory points to modern lifestyles. Squatting, which stretches the calves and Achilles tendons regularly, was a normal resting position for most of human history. Without that habitual stretching, the muscles and tendons may become more prone to involuntary contractions. People with neurological conditions like Parkinson’s disease also experience cramps at higher rates, suggesting that nerve dysfunction plays a role in many nighttime episodes.

Hydration, Electrolytes, and a Surprising Twist

Dehydration is the most commonly blamed cause of cramps, but the evidence is more nuanced than you might expect. In controlled studies, researchers had men run downhill in 95°F heat until they lost 2 percent of their body weight through sweat. That level of dehydration alone did not make their muscles more likely to cramp. Even at 3 to 5 percent dehydration in other experiments, cramp susceptibility stayed the same.

Here’s where it gets interesting: when those dehydrated participants drank plain water afterward, their muscles became significantly more cramp-prone within 30 to 60 minutes. The likely reason is that drinking water without replacing the sodium and other minerals lost in sweat dilutes what’s left in your blood. When participants instead drank a solution containing electrolytes, cramp susceptibility did not increase.

The minerals that matter most for muscle and nerve function are sodium, potassium, magnesium, calcium, and phosphate. Each plays a role in generating the electrical signals muscles need to contract and relax properly. A true deficiency in any of these can cause cramps, spasms, or weakness. But for otherwise healthy people eating a normal diet, low electrolytes are rarely the sole explanation for occasional cramps.

Medications That Cause Leg Cramps

Several common medications list muscle pain, soreness, or cramping as side effects. Cholesterol-lowering statins are among the most well-known culprits. Muscle pain is the most frequent complaint from people taking these drugs, ranging from mild soreness to discomfort severe enough to interfere with daily activities. Higher doses tend to cause more problems, and certain drug interactions can amplify the risk.

Diuretics (water pills) used for blood pressure can also trigger cramps by increasing the amount of potassium, magnesium, and sodium your body flushes out through urine. If you’ve noticed cramps starting or worsening after beginning a new medication, that connection is worth raising with your doctor.

Circulation Problems

Cramping or aching in the legs during walking or exercise that reliably goes away with rest is a hallmark of reduced blood flow, a condition called claudication. The pain typically shows up in the calves, thighs, or buttocks and feels like muscle fatigue or deep aching. It happens because narrowed arteries can’t deliver enough oxygen-rich blood to meet the muscles’ demand during movement.

As the condition progresses, the pain can begin occurring at rest or become constant. Claudication is most common in people with risk factors for artery disease: smoking, diabetes, high blood pressure, and high cholesterol. If your leg pain follows a predictable pattern of exercise and rest, a simple test comparing blood pressure at your ankle to your arm can help determine whether blood flow is the issue.

Spinal Nerve Compression

Narrowing of the spinal canal in the lower back can put pressure on the nerves that run down to your legs, causing pain, cramping, or weakness. The telltale pattern is cramping in one or both legs that worsens when you stand for a long time or walk, and improves when you lean forward or sit down. Leaning forward opens up space in the spinal canal, which temporarily relieves the pressure on those nerves. If your cramps follow this specific pattern, the source may be your back rather than your legs.

Pregnancy

Leg cramps are common during pregnancy, particularly in the second and third trimesters. The exact cause isn’t fully established, but lower levels of calcium in the blood during pregnancy may play a role. Added weight, changes in circulation, and the pressure a growing uterus places on blood vessels and nerves in the pelvis likely contribute as well. Gentle calf stretches before bed and staying well hydrated are the standard recommendations.

When a “Cramp” May Be Something Else

A blood clot in a deep leg vein can feel remarkably similar to a muscle cramp: pain or soreness that often starts in the calf, sometimes with a cramping quality. The key differences are swelling in the affected leg, skin that turns red or purple, and a feeling of warmth over the area. These symptoms may develop gradually rather than striking suddenly the way a typical cramp does. Blood clots can also occur without any noticeable symptoms. If you have calf pain along with swelling or skin color changes, especially after a period of immobility like a long flight or surgery, seek medical attention promptly.

Reducing Cramp Frequency

For occasional cramps, regular stretching of the calves and hamstrings is the simplest intervention with the most consistent support. Stretching before bed may be particularly helpful if your cramps tend to happen at night. When a cramp strikes, pulling your toes toward your shin (dorsiflexion) lengthens the calf and can help the contraction release faster.

A 2025 study published by the American Academy of Family Physicians found that vitamin K2 (specifically a form called menaquinone-7) cut the average number of nighttime cramps roughly in half among adults 65 and older. Participants who took 180 micrograms in the evening for two months dropped from about 2.6 cramps per week to fewer than one, while the placebo group actually worsened. This supplement is available without a prescription, though it should not be taken by anyone on warfarin, as it can reduce that drug’s effectiveness.

If you exercise in the heat, the research suggests that rehydrating with an electrolyte-containing drink rather than plain water is the smarter choice for cramp prevention. And if your cramps are frequent, keep track of when they happen, what you were doing, and what medications you’re taking. That pattern can help distinguish a harmless annoyance from something that deserves a closer look.