Why Do I Get Leg Cramps: Causes, Triggers & Relief

Leg cramps happen when motor neurons in your muscles fire excessively, causing a sudden, involuntary contraction that can last from a few seconds to several minutes. The most common culprits are muscle fatigue, dehydration, electrolyte imbalances, and spending long periods in one position. But cramps that keep coming back can also signal something deeper, from medication side effects to nerve compression in your spine.

What Happens Inside a Cramping Muscle

Your muscles rely on a careful balance between two signaling systems. One system (from structures called muscle spindles) tells the muscle to contract. The other (from sensors called Golgi tendon organs) tells it to relax. When everything works normally, these signals keep each other in check. A cramp happens when that balance breaks down: the “contract” signal overwhelms the “relax” signal, and the muscle locks up.

This breakdown can be triggered by fatigue, dehydration, or shifts in your electrolyte levels, particularly sodium, potassium, calcium, and magnesium. Any of these conditions make the nerves controlling your muscles more excitable, meaning they fire more easily and more often than they should. That’s why cramps tend to strike after a long day on your feet, during or after exercise, or in the middle of the night when your body has gone hours without water.

Muscle Fatigue vs. Dehydration

For decades, the standard explanation for exercise cramps was that you lost too much salt and water through sweat. That theory has a problem: cramps almost always hit one specific muscle group, usually the calves. If the cause were a body-wide electrolyte shortage, you’d expect cramps everywhere at once.

The stronger explanation, supported by the most current evidence, is neuromuscular fatigue. When a muscle is overworked or pushed beyond what it’s trained for, the protective “relax” signals from the tendon organs weaken, and the excitatory signals from the spindles take over. The result is an uncontrolled contraction in that specific, fatigued muscle. Dehydration and electrolyte loss likely make things worse by lowering the threshold at which nerves misfire, but fatigue appears to be the primary driver. This is why cramps are more common toward the end of a long run or a shift spent standing, not at the beginning.

Nighttime Cramps

Nocturnal leg cramps are especially common in adults over 50. They typically hit the calf or the sole of the foot and can jolt you awake with intense pain. The exact trigger isn’t always clear, but several factors converge at night: mild dehydration from hours without fluids, reduced blood flow from lying still, and the natural tendency of your foot to point downward in bed, which keeps the calf muscle in a shortened position. A shortened muscle is closer to its cramp threshold, so even a small involuntary nerve signal can set one off.

Medications That Cause Cramps

If your cramps started or worsened after beginning a new medication, the drug itself may be responsible. Diuretics (water pills) are the most frequent offenders among blood pressure medications. The thiazide-like diuretic indapamide, for example, lists muscle cramps as a side effect occurring in at least 5% of users. Loop diuretics like furosemide can lower calcium levels enough to trigger cramping. Even potassium-sparing diuretics, which are sometimes prescribed specifically to prevent electrolyte loss, are associated with cramps.

The pattern becomes clearer when you look at combination drugs. One common blood pressure medication (enalapril) rarely causes cramps on its own, but when it’s combined with a diuretic, the cramp rate jumps to nearly 3%. Statins (cholesterol-lowering drugs) are another well-known trigger, as are some asthma inhalers and certain medications used to treat osteoporosis. If you suspect a medication link, your prescriber can often adjust your dose or switch you to an alternative.

When Cramps Signal a Circulation Problem

Not all leg cramps are harmless. Peripheral artery disease (PAD) causes cramping or aching in the calves, thighs, or hips during walking or exercise. The pain stops when you rest, which is the hallmark clue. PAD develops when fatty deposits narrow the arteries supplying your legs, reducing blood flow to the muscles during activity.

Other signs that point to PAD rather than ordinary cramps include weak or absent pulses in your feet, shiny or discolored skin on your legs, slow-growing toenails, hair loss on the legs, and sores on the feet or toes that heal slowly. In severe cases, the pain can occur even at rest or wake you from sleep. PAD shares risk factors with heart disease (smoking, diabetes, high blood pressure, high cholesterol), so leg cramps that consistently follow this pattern are worth getting checked.

Spine and Nerve Issues

Compression of the nerves in your lower back can also trigger leg cramps, particularly at night. Lumbar spinal stenosis, a narrowing of the spinal canal that’s common with aging, puts pressure on nerve roots that control leg muscles. Research has found a direct relationship between the degree of spinal canal narrowing and the likelihood of nocturnal cramps. When nerve roots are chronically compressed, they become hyperexcitable, firing off signals that cause muscles to contract involuntarily.

If your leg cramps come with back pain, leg numbness, weakness, or pain that worsens when you stand or walk and improves when you sit or lean forward, spinal stenosis could be the underlying cause. Abnormal reflexes at the knee are another clue that nerve compression is involved.

Pregnancy and Leg Cramps

Leg cramps affect roughly 58% of pregnant women, with the highest rates in the third trimester. The growing uterus puts pressure on blood vessels and nerves in the pelvis, which reduces blood return from the legs. A more sedentary lifestyle during late pregnancy compounds the problem: less muscle activity means more fluid accumulates in the tissues, further compressing nerves and blood vessels. The combination of extra weight, shifting mineral demands, and reduced circulation creates near-perfect conditions for nighttime calf cramps.

Does Magnesium Actually Help?

Magnesium supplements are one of the most popular home remedies for leg cramps, but the evidence is disappointing for most people. A meta-analysis of seven randomized controlled trials found that magnesium was no more effective than a placebo at reducing cramp frequency in the general (non-pregnant) population. In pregnant women, there was a small benefit, roughly one fewer cramp per week compared to placebo. If you’re pregnant and dealing with frequent cramps, magnesium may be worth trying. For everyone else, it’s unlikely to make a meaningful difference.

Why You Should Avoid Quinine

Quinine, an antimalarial drug once widely prescribed for leg cramps, is no longer considered safe or effective for that purpose. The FDA has issued explicit warnings: quinine carries a risk of serious blood disorders, including conditions where your immune system destroys your own platelets. These reactions can lead to kidney failure requiring dialysis, and fatalities have been reported. Quinine remains FDA-approved only for treating malaria. If you’ve been using quinine tablets or drinking large amounts of tonic water (which contains small amounts of quinine) for cramps, the risk far outweighs any benefit.

Stretches and Practical Relief

When a cramp strikes, the fastest relief comes from stretching the cramped muscle. For a calf cramp, flex your foot upward (pulling your toes toward your shin) and hold until the contraction releases. Standing and pressing your heel firmly into the floor works too. Walking around for a few minutes afterward helps the muscle fully relax.

For prevention, a simple wall stretch done consistently can reduce cramp frequency. Stand about three feet from a wall, lean forward with your arms outstretched and palms flat on the wall, and keep your heels on the ground. Hold for a count of five, then repeat for at least five minutes. Doing this three times a day keeps the calf muscles lengthened and less prone to spontaneous contraction, especially at night.

Beyond stretching, staying hydrated throughout the day (not just during exercise), wearing supportive shoes, and avoiding prolonged sitting or standing in one position all help. If you get nighttime cramps, try keeping your sheets and blankets loose at the foot of the bed so they don’t push your feet into a pointed position while you sleep.