Leg cramps happen when a muscle suddenly contracts and won’t relax, usually lasting a few seconds to several minutes. The most common culprits are muscle fatigue, dehydration, low electrolyte levels, and nerve signaling problems that worsen with age. Between 50 and 60 percent of adults experience nocturnal leg cramps, and the frequency increases as you get older.
Two Competing Theories Explain Cramps
Scientists have debated the root cause of muscle cramps for decades, and two main explanations have emerged. The first centers on dehydration and electrolyte loss. When you sweat heavily or don’t drink enough fluid, the balance of minerals in and around your muscle cells shifts. Fluid migrates out of the spaces between cells, increasing pressure on nearby nerve pathways. That pressure distorts nerve signaling and can trigger an involuntary contraction.
The second theory focuses on your nervous system. Newer evidence points to a malfunction at the spinal cord level, where the signals telling a muscle to contract become overactive while the signals telling it to relax become too weak. Normally, sensors in your tendons act as a brake, preventing excessive contraction. When those sensors are fatigued or suppressed, the “go” signal overwhelms the “stop” signal, and the muscle locks up. This theory helps explain why cramps tend to hit muscles that are already tired or shortened, even when you’re well-hydrated.
Nighttime Cramps and Aging
Nocturnal leg cramps are the most common type, typically striking the calf or foot while you’re in bed. They affect women slightly more often than men, and about 20 percent of people who get them have episodes frequent enough to seek medical attention. The reason they cluster at night likely involves the position of your feet during sleep. When you lie with your toes pointed downward, the calf muscle sits in a shortened position for hours, making it more prone to spontaneous contraction.
Age plays a significant role. As you get older, you naturally lose muscle mass, and the remaining muscle fatigues more easily. Nerve function also changes with age, making the signaling imbalances described above more likely. Older adults are also more likely to take medications that affect fluid balance or mineral levels, compounding the problem.
Exercise-Related Cramps
If your cramps hit during or after physical activity, intensity and fatigue are the biggest drivers. A study of over 1,300 marathon runners found that among those prone to cramping, 85 percent experienced cramps during racing rather than training, 80 percent cramped after the 30-kilometer mark, and 60 percent identified muscle fatigue as the primary trigger. Fast pace and hill running were also major factors.
Interestingly, the study found no significant difference in drinking patterns or sodium intake between crampers and non-crampers. What did differ was genetics and flexibility: runners who cramped were nearly twice as likely to have a family history of cramping and spent less time stretching daily (about six minutes versus eight). The muscles most affected were those that cross two joints, like the calf (which crosses the knee and ankle) and the hamstring (which crosses the hip and knee), because these muscles are biomechanically more vulnerable to fatigue.
Electrolyte Imbalances
Low levels of key minerals genuinely do cause cramps, though this tends to matter most when levels drop significantly rather than being slightly off. Potassium is a common culprit. When blood potassium falls below normal, early symptoms include weakness, fatigue, and leg cramps. This can happen from prolonged vomiting, diarrhea, heavy sweating, or certain medications.
Low calcium triggers a different pattern. As levels drop further, you’ll first notice tingling in your fingers, toes, and around your mouth, followed by muscle cramps and spasms that can become severe. Magnesium deficiency can also contribute, since magnesium helps regulate both potassium and calcium levels. If one mineral is low, the others often follow.
Medications That Cause Cramps
Several common drug classes can trigger or worsen leg cramps. Diuretics (water pills) used for blood pressure are among the most frequent offenders because they increase urination and flush out potassium, sodium, and magnesium. Cholesterol-lowering statins are another well-known cause. Mild muscle pain is a common side effect of statins, and in rare cases, they can cause more serious muscle breakdown that includes severe cramping and soreness. The risk increases when statins are combined with certain other medications.
If your cramps started or worsened after beginning a new medication, that timing is worth noting and discussing with your prescriber.
Pregnancy Cramps
Leg cramps are common during the second and third trimesters, typically striking at night. The exact mechanism isn’t fully understood, but the added weight changes how your leg muscles work throughout the day, and some research suggests that lower blood calcium levels during pregnancy play a role. Unlike in the general population, magnesium supplements may offer pregnant women a small benefit, reducing cramps by roughly one extra episode every three weeks compared to placebo. It’s a modest effect, but for someone waking up nightly with calf cramps, it may be worth trying.
What Actually Helps Prevent Cramps
Stretching before bed is the most consistently recommended prevention strategy for nighttime cramps. A simple calf stretch, where you stand facing a wall with one foot back and press the heel into the floor, held for 30 seconds on each side, targets the muscle most commonly affected. Doing this as part of your bedtime routine can reduce both the frequency and severity of episodes.
Staying hydrated matters, especially if you exercise, work in heat, or take diuretics. You don’t need to overdo it. Drinking enough that your urine stays pale yellow is a practical target. Eating potassium-rich foods like bananas, potatoes, and leafy greens supports electrolyte balance, as does including adequate calcium and magnesium from dairy, nuts, and whole grains.
As for magnesium supplements specifically, a systematic review of randomized trials found that magnesium does not appear effective for nighttime cramps in the general population. Despite its popularity as a cramp remedy, the evidence simply doesn’t support it for most adults. The benefit seen in pregnant women was real but small.
When a cramp strikes, the fastest relief comes from actively stretching the affected muscle. For a calf cramp, pull your toes toward your shin, either by hand or by standing and pressing your heel flat. Walking around for a few minutes after the cramp releases helps the muscle fully relax and reduces lingering soreness.
When Cramps Signal Something Else
Most leg cramps are harmless, but certain patterns deserve attention. If you get cramping pain in your legs specifically during walking or climbing stairs, and it reliably goes away when you rest, that pattern is characteristic of peripheral artery disease, a condition where narrowed arteries reduce blood flow to the legs. This pain typically affects the calves, thighs, or hips and can range from mild to severe.
A more urgent concern is deep vein thrombosis, a blood clot in a deep leg vein. The symptoms can mimic a cramp: pain, cramping, or soreness that often starts in the calf. The distinguishing signs are swelling in one leg (not both), skin that looks red or purple over the area, and a feeling of warmth in that spot. DVT can sometimes produce no noticeable symptoms at all. If you have leg pain with unexplained swelling, warmth, or skin color changes in one leg, that combination warrants prompt medical evaluation because clots can travel to the lungs.
Cramps that are persistent, worsening over time, not relieved by stretching, or accompanied by muscle weakness may also point to an underlying nerve or metabolic condition worth investigating.