Leg cramps at night: causes, relief and prevention

A sudden, painful tightening of the calf at night is familiar to most adults and becomes more common with age. In many cases no cause is found, and the cramps are harmless, but you are not helpless against them. Here is how to stop a cramp in seconds, what reduces how often they come, why magnesium does less than the adverts promise, and when cramps are a sign of something else.

Illustration of a leg and foot with a red patch on the calf and a curved red arrow showing the foot being flexed, on a pale blue background

In short

  • Leg cramps are common, usually harmless and short. The NHS says they typically last from seconds to 10 minutes, and the muscle can stay sore for up to a day.
  • To stop one, stretch and massage the muscle, or stand and put weight on the leg.
  • Regular calf stretching, including before bed, may reduce cramps, though it may not stop them completely.
  • A review of magnesium trials concluded that it is unlikely to give older adults a meaningful reduction in night cramps.
  • Cramps with leg swelling, numbness or weakness, or cramps that disrupt sleep, are reasons to see a provider.

How to stop a cramp right now

  1. Stretch.Straighten the leg and flex the foot toward the shin, as Cleveland Clinic describes.
  2. Massage.Gently rub the tight muscle. The NHS says stretching and massaging may help.
  3. Stand up.The NHS says standing with weight on the affected leg may ease it, and Cleveland Clinic suggests pressing your feet into the floor and walking around.
  4. Add warmth or cold.Cleveland Clinic suggests heat from a heating pad or warm bath, or ice wrapped in a towel, once the muscle has loosened.
  5. Treat the soreness.The NHS says paracetamol or ibuprofen can relieve soreness afterward, but it will not work during the cramp itself.

Why your legs cramp

The NHS lists ageing, muscle strain during exercise, particularly in hot or humid weather, pregnancy (usually the later stages), dehydration, heavy alcohol use causing liver disease, and certain medicines as causes. It adds that some cramps have no known cause.

MedlinePlus says the most common cause is straining or overusing a muscle, and lists nerve compression, low levels of electrolytes such as magnesium, potassium or calcium, poor blood flow to the muscles, pregnancy and dialysis as other causes.

Cleveland Clinic notes that night cramps may be linked to long periods of sitting, overusing muscles, standing on concrete and poor posture, and that older age and being a woman raise the risk.

Medicines that can trigger cramps

The NHS names statins, taken for cholesterol, and diuretics, taken for blood pressure or fluid. Cleveland Clinic's longer list also includes certain asthma, hormone, seizure and pain medicines, and some antidepressants. If you started a new medicine around the time your cramps began, tell your provider.

Never stop a prescribed medicine on your own. Ask your provider about alternatives, as Cleveland Clinic advises.

Prevention: what to do in the evening

  • Stretch your calves, daily and before bed. The NHS describes standing facing a wall, hands on it, leaning forward until the calf stretches, and repeating for about five minutes, three times a day, with the last session before bed.
  • Walk or do gentle exercise during the day, and mild walking or biking before bed, as Cleveland Clinic suggests.
  • Stay hydrated, and limit alcohol and caffeine.
  • Wear supportive shoes, and experiment with your sleep position.
  • Take vitamins and medicines exactly as prescribed.

Magnesium and other popular remedies

A systematic review of magnesium for muscle cramps concluded that it is unlikely to provide a meaningful reduction in cramps for older adults with idiopathic night cramps, with changes in cramp frequency that were small and not statistically significant. For cramps in pregnancy, the review found the evidence conflicting and too limited to pool.

The review found oral magnesium caused side effects similar to placebo, with diarrhea the main possible exception. Cleveland Clinic lists magnesium and vitamin B complex among options some experts suggest, only with a provider's direction, and notes that no vitamin is reliably effective for every cramp.

The NHS says that if exercise does not help, a provider may prescribe quinine tablets, which are not suitable for everyone, so the benefits and risks need discussing first. MedlinePlus adds that medicines to prevent cramps are not always effective and may cause side effects.

Is it really a cramp?

Cleveland Clinic explains how to tell a cramp from restless legs syndrome: both tend to happen at night or at rest, but cramps cause severe pain, while restless legs syndrome is uncomfortable but not agonizing. Restless legs produce a crawling sensation and a strong urge to move the legs, and moving relieves the urge, though some discomfort remains.

If your legs feel restless rather than locked, mention that to your provider, because the evaluation and treatment differ.

When to see a doctor and red flags

The NHS advises seeing a provider if cramps disturb your sleep, you also have numbness or swelling in your legs, or cramps last longer than 10 minutes. MedlinePlus adds severe or frequent cramps, cramps that do not improve with stretching and fluids, and those with redness, warmth or muscle weakness.

Cleveland Clinic notes that cramps can occasionally signal other conditions, such as diabetes, kidney, heart or liver disease and nerve problems, which is why a persistent pattern deserves a check-up.

Red flags: go to the emergency department if a cramp lasts longer than 10 minutes or becomes unbearably painful. Call 911 if a swollen, red or warm leg comes with shortness of breath or chest pain.

Questions to bring:

  • Could one of my medicines be contributing?
  • Do I need blood tests for electrolytes or other conditions?
  • Is this a cramp or restless legs syndrome?
  • What stretching routine should I follow?

Questions and answers

Does magnesium help night cramps?

A systematic review found it is unlikely to give older adults a meaningful benefit, and the evidence in pregnancy is mixed. If you want to try it, ask your provider first.

What should I do during a cramp?

Straighten the leg and flex your foot toward the shin, rub the muscle, and stand on the leg. Wait until the cramp has passed to take a painkiller.

Why do cramps strike at night?

Cleveland Clinic says most reported cramps happen at night, and notes that long periods of sitting, tired muscles and poor posture may play a part.

Are cramps in pregnancy dangerous?

The NHS lists pregnancy, usually in the later stages, as a common cause. Mention them at your prenatal visit, and call your provider if you have swelling, redness or pain in one leg.

How do cramps differ from restless legs syndrome?

Cramps are a painful, locked muscle, while restless legs bring a crawling urge to move that is relieved by moving, according to Cleveland Clinic.

Sources

  1. NHS — Leg cramps
  2. MedlinePlus — Muscle cramps
  3. Cleveland Clinic — Leg cramps
  4. PubMed Central — Magnesium for skeletal muscle cramps

Sources checked on 29 October 2026.