Need a Human Doctor?

We guide you when professional in-person care is required.

Symptom Checker

Why Do I Get Leg Cramps at Night?

m. is almost always a calf muscle locking into a hard, painful spasm for a few seconds to several minutes, and in most people it is caused by muscle fatigue, mild dehydration, or hours spent sitting or standing during the day rather than anything dangerous.

Why Do I Get Leg Cramps at Night?
SymptomsNocturnal Leg Crampssymptom-check
Written By: DocAi Health Editorial Team
Last Updated: 2026-08-24
Medically Reviewed By: DocAi Health Medical Review Team
Medical Disclaimer: This article is for general informational and educational purposes only and is not medical advice. It does not create a doctor-patient relationship and is not a substitute for professional diagnosis or treatment by a qualified healthcare provider. Never disregard or delay seeking professional medical advice because of something you have read here. If you think you may have a medical emergency, call 911 or your local emergency number right away. Health information can change and this guidance is general and US-focused, so consult a licensed clinician in your own country about your specific situation.
A leg cramp that wakes you up at 2 a.m. is almost always a calf muscle locking into a hard, painful spasm for a few seconds to several minutes, and in most people it is caused by muscle fatigue, mild dehydration, or hours spent sitting or standing during the day rather than anything dangerous. Nighttime leg cramps become more common with age, in pregnancy, and with certain medications like diuretics and statins. This article walks through why the cramps happen, what actually helps in the moment and going forward, and the small number of situations, like a swollen red leg or a cramp that will not let go, where the pain is a signal to get checked rather than stretched out.

What Is Actually Happening in Your Calf

A nocturnal leg cramp is an involuntary, sustained contraction of a skeletal muscle, most often the calf (gastrocnemius), though it can also grip the foot arch or the back of the thigh. Unlike a muscle spasm during exercise, this one hits while you are still or asleep, which is part of why it feels so alarming. The muscle fiber essentially misfires and will not release, and the surrounding tissue can stay tender for a day afterward from the sudden, forceful contraction.
Researchers have not pinned down one single trigger. The leading explanation involves the nerves that control muscle contraction becoming more excitable when a muscle is already shortened, tired, or under-hydrated, so a small nerve signal that would normally pass without effect instead sets off a full spasm. Lying in bed with your foot pointed downward, which many people do without noticing, shortens the calf muscle and can make it more prone to firing this way.

The Common, Non-Urgent Causes

Most nighttime leg cramps trace back to a handful of everyday factors, often stacked together:
Muscle overuse and prolonged positions. A long day of standing, an unusually hard workout, or hours in a car or at a desk with legs in one position can leave calf muscles fatigued and irritable by bedtime.
Mild dehydration and electrolyte shifts. Not drinking enough fluid, sweating heavily, or losing fluid through illness can shift the sodium, potassium, calcium, and magnesium levels that muscles and nerves depend on to contract and relax normally.
Pregnancy. Cramps are common in the second and third trimester, likely from a combination of weight change, altered circulation, and shifting mineral levels, and they usually resolve after delivery.
Age. Cramp frequency rises steadily after age 50, possibly because muscle tendons naturally shorten and nerve signaling changes with age.
Medications. Diuretics (water pills) used for blood pressure can deplete potassium and magnesium. Statins for cholesterol are linked to muscle aches and cramping in some people. Asthma medications, certain osteoporosis drugs, and some Parkinson's medications have also been associated with cramps. Do not stop a prescribed medication on your own; ask your prescriber or pharmacist whether an alternative or a dose adjustment makes sense.
Sitting or standing for long stretches at work. Jobs that keep you on your feet on hard floors, or seated with legs bent for hours, are consistently linked to more frequent nighttime cramps.

Causes That Deserve a Closer Look

A smaller share of leg cramps point to something that benefits from a medical workup rather than home remedies alone.
Peripheral artery disease (PAD). When the arteries that supply the legs narrow from plaque buildup, the calf muscles do not get enough blood flow, especially under demand. This can show up as cramping pain with walking that eases with rest (claudication), and sometimes as cramping at night when circulation drops further with the legs elevated in bed. Cold feet, leg pain that improves when you dangle your leg off the bed, and slow-healing sores on the feet are supporting clues.
Nerve compression. A pinched nerve in the lower spine, such as from spinal stenosis or a herniated disc, can cause cramping, tingling, or weakness that runs down the leg, often worse when lying flat.
Kidney disease and thyroid problems. Impaired kidney function changes how the body handles electrolytes and can trigger cramping, as can an underactive thyroid. Both are found with a simple blood test.
Liver disease. Cramping is a recognized symptom in some forms of chronic liver disease, thought to relate to fluid and electrolyte shifts.
Structural leg problems. Flat feet or other alignment issues can put uneven strain on calf muscles over years.

What Helps in the Moment

When a cramp hits, the fastest relief is usually to gently stretch the muscle in the opposite direction of the cramp. For a calf cramp, straighten your leg and pull the top of your foot up toward your shin, either with your hand, a towel looped around the foot, or by standing and pressing your heel into the floor with your knee slightly bent. Hold the stretch until the spasm eases, then massage the muscle and apply a warm compress or heating pad, since heat relaxes the muscle while ice can help with soreness afterward. Walking around the room for a minute after the spasm passes can also help the muscle fully release.

What Helps Prevent Them

A few habits reduce how often cramps show up for most people, though none work for everyone:
Stretch before bed. A few minutes of calf and hamstring stretching in the evening, especially after exercise, is one of the more consistently reported ways to cut down on nighttime cramps.
Stay hydrated through the day. Spread fluid intake across the day rather than trying to catch up right before bed, which mostly just means more trips to the bathroom.
Check your magnesium and potassium intake. Foods like leafy greens, beans, nuts, bananas, and yogurt supply both minerals. Talk to your doctor before starting a magnesium supplement, particularly if you have kidney disease, since the kidneys clear excess magnesium and impaired kidneys cannot do that safely.
Adjust your sleep position. Loosening the top bedsheet so your feet are not forced into a pointed-down position, or sleeping with a pillow supporting your feet at a neutral angle, can reduce the shortened calf position that seems to invite cramps.
Review your medications with your doctor or pharmacist. If cramps started or worsened after beginning a new diuretic, statin, or asthma medication, mention it at your next visit rather than waiting.
Wear supportive shoes. If your day involves standing on hard floors, a cushioned, supportive shoe reduces strain on calf muscles that can carry into the evening.

When Cramps Are Frequent Rather Than Occasional

An occasional cramp after a hard workout or a hot day is not a red flag. Cramps that wake you up several nights a week, that are getting more frequent or more painful over weeks, or that are starting to interfere with getting enough sleep are worth bringing up with a doctor, since they may point to one of the medical causes above and a basic blood test or medication review can often identify a fixable contributor.

When to Seek Medical Care

When to Seek Urgent or Emergency Care

Almost all nighttime leg cramps are benign muscle spasms that pass in minutes. A small number of leg symptoms that can feel similar at first are signs of a blood clot or a blocked artery, and those need urgent evaluation rather than stretching and waiting. This guidance is in addition to, not a replacement for, the general disclaimer above.

Emergency, call 911 or go to the emergency room immediately if:

  • One leg suddenly becomes swollen, warm, red, or tender, especially if it also comes with chest pain, shortness of breath, or coughing up blood. This combination can signal a blood clot (deep vein thrombosis) that has traveled to the lungs.
  • A leg suddenly turns pale, cold, or blue, with severe pain and a weak or absent pulse in the foot. This can mean a sudden blockage of blood flow to the leg and can threaten the limb within hours.
  • The pain is severe, out of proportion to what you would expect, and comes with tight, swollen skin over the muscle after an injury or unusually intense exercise. This pattern can indicate compartment syndrome, which can damage muscle and nerve tissue if not treated quickly.
  • Sudden weakness, numbness, or an inability to move the leg or foot accompanies the cramping.

See a doctor soon (same-day or next available appointment) if:

  • Cramps are waking you up several nights a week or are getting more frequent or more severe over a period of weeks.
  • You have new leg pain that occurs with walking and eases with rest, especially with cold feet or slow-healing sores, which can point to peripheral artery disease.
  • Cramping started or worsened after beginning a new diuretic, statin, or other prescription medication.
  • Cramps come with ongoing tingling, numbness, or weakness that runs down the leg, which can suggest nerve compression in the lower spine.
  • You have known kidney disease, liver disease, or thyroid problems and are having more frequent cramping than usual.
  • Cramps are frequent enough during pregnancy to disrupt sleep most nights.
Still concerned about your symptoms?
Use the DocAi Health AI Symptom Checker for a personalized health assessment and guidance.
Start Your Assessment →

Frequently Asked Questions

Why do leg cramps only seem to happen at night?

Lying down often shortens the calf muscle when your foot points downward under the covers, and a muscle that is already shortened is more prone to a sudden, involuntary spasm. Lower activity and cooler body temperature at night may also play a role in how nerves signal the muscle.

Are night leg cramps a sign of low potassium?

Low potassium can contribute to muscle cramping, particularly in people taking diuretics or with limited fruit and vegetable intake, but most people with occasional nighttime cramps have normal electrolyte levels. A blood test can check this if cramps are frequent or you have other symptoms like weakness or an irregular heartbeat.

Does drinking more water stop leg cramps?

Staying hydrated through the day can help in people whose cramps are linked to fluid loss from heat, exercise, or illness, but it will not fix cramps caused by medication, nerve compression, or reduced blood flow. If cramps continue despite good hydration, the cause is likely something else.

Can pregnancy cause leg cramps at night?

Yes, leg cramps are common in the second and third trimester of pregnancy, likely from a combination of weight gain, changes in circulation, and shifting calcium and magnesium levels. They typically improve within weeks after delivery. Mention frequent cramps to your prenatal care provider so other causes are not missed.

Should I take a magnesium supplement for leg cramps?

Magnesium may help some people, but the evidence is mixed and it is not a guaranteed fix. Talk to your doctor before starting a supplement, especially if you have kidney disease, since the kidneys clear excess magnesium and cannot always do that safely when function is reduced.

Can a statin or blood pressure medication cause night leg cramps?

Yes, diuretics can lower potassium and magnesium, and statins are linked to muscle aches and cramping in some people. If cramps began after starting a new medication, tell your prescriber or pharmacist rather than stopping the medication on your own, since an adjustment or alternative may resolve it.

How do I tell a normal leg cramp from a blood clot?

A typical cramp is a brief, painful spasm that eases within minutes with stretching. A blood clot more often causes ongoing swelling, warmth, redness, and tenderness in one leg that does not resolve, and it can come with chest pain or shortness of breath if it travels to the lungs. That combination needs emergency care right away.

When should I see a doctor about leg cramps at night?

See a doctor if cramps happen several nights a week, are getting worse over weeks, disrupt your sleep, or come with numbness, weakness, cold feet, or pain that worsens with walking. A basic exam and blood work can often find a treatable cause.

Sources

Need a Human Doctor?
We guide you when professional in-person care is required.
Connect with a Board-Certified Doctor