Waking up with aching, cramping, or restless legs is miserable — and surprisingly common. Nighttime leg pain has a range of causes, from completely benign to occasionally serious. Here are the 8 most common reasons your legs hurt at night and how to get relief.
Common Causes of Nighttime Leg Pain
The most common causes are: muscle cramps from dehydration or electrolyte imbalance, Restless Legs Syndrome, poor circulation, overuse or muscle fatigue from activity, medication side effects, nerve problems, varicose veins, and growing pains in children and teenagers.
1 Nocturnal Leg Cramps
Easy Fix
Nocturnal leg cramps are sudden, involuntary contractions of the calf or foot muscles that cause intense pain and a hard, visible muscle knot. They strike during sleep or when relaxing in bed, last seconds to minutes, and leave the muscle sore for hours afterward. They affect up to 60% of adults at some point.
Fix: When a cramp strikes, immediately stand up and put weight on the affected leg, or pull your toes forcefully toward your shin to stretch the calf. For prevention, stretch your calves before bed: stand facing a wall, step one foot back, press the heel down, hold for 30 seconds each side.
2 Electrolyte Imbalance and Dehydration
Easy Fix
Electrolytes — particularly magnesium, potassium, calcium, and sodium — regulate how muscle fibers contract and relax. Dehydration concentrates these electrolytes and disrupts the delicate balance needed for smooth muscle function. Low magnesium is particularly associated with nocturnal cramps.
Fix: Drink 2-3 liters of water daily. Eat magnesium-rich foods (nuts, seeds, dark leafy greens) and potassium-rich foods (bananas, sweet potato, avocado). If cramps are frequent and diet does not help, ask your doctor to test your electrolyte levels.
3 Restless Legs Syndrome (RLS)
See a Doctor
RLS causes an irresistible urge to move your legs, usually described as a crawling, tingling, or aching sensation deep in the legs. It is worst in the evening and at night when lying down, and is temporarily relieved by movement. It affects 5-10% of the population and significantly disrupts sleep quality.
Fix: See your doctor — RLS has specific treatments. First, get your iron and ferritin levels checked, as iron deficiency is a direct cause of RLS in many cases. Iron supplementation can be curative. For cases not related to iron deficiency, prescription medications and lifestyle changes (regular exercise, reducing caffeine and alcohol) are effective.
4 Muscle Fatigue from Overuse
Easy Fix
A day of unusual activity — a long hike, standing for hours, or starting a new exercise routine — causes micro-tears in muscle fibers that produce the familiar aching and soreness known as DOMS (Delayed Onset Muscle Soreness). The aching typically peaks 24-48 hours after the activity and is worst at rest, particularly at night when there are no distractions.
Fix: Rest, light movement, and time are the primary treatments. Gentle stretching, a warm bath before bed, and over-the-counter anti-inflammatories can help. Legs sore from overuse do not need rest for more than 1-2 days — light walking actually speeds recovery by increasing blood flow.
5 Poor Circulation (Peripheral Artery Disease)
See a Doctor
Peripheral artery disease (PAD) is narrowing of the arteries that supply blood to the legs. It causes leg cramping, aching, or fatigue that can be worse at night or during exertion. A telltale sign of PAD is pain that is relieved by hanging the leg down off the bed (increasing blood flow via gravity) — this distinguishes it from venous problems, which are relieved by elevation.
Fix: PAD is a serious condition associated with heart disease risk. If you have risk factors (smoking history, diabetes, high blood pressure) and experience leg pain at night, see your doctor for an ankle-brachial index (ABI) test, which is painless and can diagnose PAD in minutes.
6 Varicose Veins and Venous Insufficiency
See a Doctor
Varicose veins are enlarged, damaged veins that fail to efficiently pump blood back up to the heart. Blood pools in the lower legs, causing aching, heaviness, and a throbbing pain that worsens throughout the day and peaks in the evening and night. Legs that feel heavy and tired after standing are a classic symptom.
Fix: Elevate your legs above heart level for 15-20 minutes before bed — this drains pooled blood and typically provides immediate relief. Compression stockings worn during the day reduce pooling significantly. Severe cases can be treated by a vascular specialist with procedures to close or remove the affected veins.
7 Nerve Pain (Peripheral Neuropathy)
See a Doctor
Peripheral neuropathy — nerve damage in the extremities — causes burning, tingling, shooting, or stabbing pain in the legs and feet. It is often worse at night when there are fewer distractions and when temperature changes affect nerve sensitivity. Diabetes is the most common cause, but vitamin B12 deficiency, alcoholism, and certain medications can also cause it.
Fix: See your doctor for nerve conduction testing and blood work to identify the cause. For diabetic neuropathy, strict blood sugar control slows progression significantly. Vitamin B12 deficiency-related neuropathy is reversible with supplementation. Prescription medications can help manage nerve pain that does not respond to addressing the underlying cause.
8 Medication Side Effects
Talk to Your Doctor
Several common medications list leg cramps or leg pain as known side effects: statins (cholesterol medications), diuretics (water pills), beta-blockers, certain antidepressants, and long-term use of proton pump inhibitors (which reduce magnesium absorption). If your leg pain started after beginning a new medication, this connection is worth investigating.
Fix: Do not stop any prescription medication without discussing it with your doctor first. Mention the timing of when leg pain started relative to starting the medication. Often a dosage adjustment, switching to a different medication in the same class, or supplementing magnesium resolves the problem.
Bottom Line
Most nighttime leg pain from cramps, soreness, or mild aching responds well to stretching before bed, staying hydrated, and ensuring adequate magnesium intake. Elevate your legs for 15 minutes before sleeping if you have venous-type aching. If your leg pain is severe, getting worse, accompanied by swelling or redness, or involves the characteristic urge-to-move feeling of RLS, see your doctor — effective treatments are available for all of these conditions.