Why Do My Legs Hurt at Night? Causes and Relief

Nighttime leg pain is extremely common, and it usually comes down to one of a handful of causes: muscle cramps, restless legs, poor circulation, or nerve compression. Between 50 and 60 percent of adults experience nocturnal leg cramps alone, so if you’re lying in bed wondering why your legs ache or seize up, you’re far from unusual. The cause matters, though, because each one calls for a different response.

Nocturnal Leg Cramps

The most frequent culprit is a sudden, involuntary tightening of the calf or foot muscles. These cramps hit without warning, often jolting you awake, and last an average of nine minutes per episode. The muscle can feel sore for hours afterward. They tend to strike more often with age, during pregnancy, and after a day of heavy physical activity or prolonged sitting.

The exact mechanism isn’t fully understood, but dehydration, electrolyte imbalances, and muscle fatigue all play roles. Sitting in one position for long stretches during the day can shorten the calf muscles, making them more prone to cramping once you’re still in bed. Certain medications, particularly diuretics and cholesterol-lowering drugs, increase cramp frequency as well.

Restless Legs Syndrome

Restless legs syndrome (RLS) feels different from a cramp. Instead of a sharp contraction, you get an uncomfortable crawling, tingling, or pulling sensation deep in the legs, paired with an almost irresistible urge to move them. The hallmark pattern has four features: the urge to move starts or worsens at rest, it’s partially relieved by walking or stretching, it’s worse in the evening and nighttime, and it comes with uncomfortable sensations in the legs.

RLS affects roughly 7 to 10 percent of the population. It’s linked to low iron stores in the brain, and it runs in families. If your legs feel restless rather than painfully cramped, and moving around brings temporary relief, this is likely what you’re dealing with. A blood test checking your iron levels is usually the first step in sorting it out.

Circulation Problems

Two vascular conditions commonly cause leg pain that shows up or worsens at night: chronic venous insufficiency and peripheral artery disease.

Venous Insufficiency

Your leg veins contain one-way valves that push blood back up toward your heart. When those valves weaken or become damaged, blood pools in the lower legs, increasing pressure and causing swelling, heaviness, and cramping, particularly at night. Nighttime cramping is a recognized symptom of chronic venous insufficiency. You might also notice visible varicose veins, skin discoloration around the ankles, or legs that feel increasingly heavy as the day goes on.

Peripheral Artery Disease

Peripheral artery disease (PAD) narrows the arteries supplying blood to the legs. In its earlier stages, PAD causes pain during walking that goes away with rest. But when the disease progresses, pain can occur while lying down or even wake you from sleep. This is called rest pain, and it signals that the legs aren’t getting enough blood flow even at baseline. PAD rest pain typically affects the feet and toes and may improve briefly when you dangle your legs over the side of the bed, letting gravity help push blood downward.

Nerve Compression From the Spine

Narrowing of the spinal canal in the lower back, called lumbar spinal stenosis, can compress the nerves that travel down into the legs. This produces pain, tingling, or numbness that often flares at night when you’re lying flat. The compression reduces blood flow to the nerve roots themselves, and over time, prolonged pressure can cause damage that doesn’t resolve quickly, even with treatment. People with spinal stenosis often find that bending slightly forward (like leaning on a shopping cart) eases the pain, while lying flat or arching the back makes it worse.

What You Can Do Tonight

For cramps, the most effective immediate response is stretching. Stand facing a wall with one leg behind you, knee straight and heel flat on the floor. Slowly lean forward until you feel a stretch in the calf, and hold for 30 to 60 seconds. Repeat on the other side. Doing this stretch before bed, not just during a cramp, can reduce how often they happen.

Staying hydrated throughout the day helps, especially if you’re active or take medications that increase fluid loss. If your legs feel heavy or swollen, elevating them before bed makes a real difference. Even a modest elevation of 6 to 8 inches using a wedge pillow or stacked pillows under the calves and ankles can reduce venous pressure. The key is creating a gentle incline that supports the entire leg rather than bending at the knee, which can actually restrict blood flow. Sleeping on your left side also helps circulation by reducing pressure on the large vein that carries blood from the lower body back to the heart.

Magnesium: Does It Actually Help?

Magnesium is one of the most popular home remedies for nighttime leg cramps, but the evidence is underwhelming. A systematic review of 11 randomized controlled trials found no reduction in leg cramps from magnesium supplementation. In studies lasting four weeks, there was no meaningful difference in cramp frequency between magnesium and placebo.

There is one exception. A trial of 184 patients taking magnesium oxide daily for 60 days showed a significant reduction in cramp frequency, from about 5.4 cramps per week down to 1.9, compared to a smaller drop in the placebo group. So if you want to try magnesium, short courses of a few weeks probably won’t do much. You’d need to commit to at least two months to see whether it helps. One thing to avoid entirely: quinine. Though it was once prescribed for leg cramps, the FDA has warned that quinine should not be used for this purpose because it carries risks of severe bleeding, kidney damage, irregular heartbeat, and serious allergic reactions.

Signs That Need Medical Attention

Most nighttime leg pain is benign, but certain patterns point to something more serious. Pay attention if your leg is swollen on one side (which can signal a blood clot), if the skin is unusually pale or cool to the touch, or if you notice redness and warmth in one area. Numbness or weakness in the leg, pain that’s rapidly getting worse with no clear cause, or swelling in both legs combined with breathing difficulty all warrant prompt evaluation. Calf pain that develops after a long period of travel, like a flight or car ride, also deserves a call to your doctor because of the blood clot risk.

If your nighttime leg pain follows the PAD pattern (worsening over months, starting as exercise-related pain and progressing to rest pain), that’s worth bringing up sooner rather than later, since early treatment can prevent the disease from advancing.