Leg cramps at night: causes and what helps
By Gonçalo, founder of Rainu · Updated 18 October 2026 · 6 min read
Short answer: night leg cramps are very common, usually harmless, and most often have no clear cause. Tight calf muscles, low electrolytes, losing fluid through sweat, vomiting or diarrhea, some medicines, caffeine and late pregnancy can make them more likely. Stretch the calf to stop one. To prevent them, stretch before bed and drink enough, especially after exercise. Magnesium and quinine haven't been shown to work.
What is a leg cramp?
A sudden, brief, involuntary and usually painful tightening of a muscle. Cramps are common in healthy people, mostly in middle-aged and older adults. Sleep-related leg cramps usually hit the calf and foot, curling the foot and toes downward. MSD Manual, Muscle cramps (2025).
What causes leg cramps at night?
The most common type is benign leg cramps, which happen at night for no known reason. MSD Manual. Some things raise the odds:
- Tight calf muscles, from not stretching, inactivity, or fluid that keeps building up in the lower legs.
- Low potassium, magnesium or calcium, which can come from some diuretics, heavy drinking, hormonal disorders, low vitamin D, or losing fluid (and with it electrolytes).
- Heavy sweating without replacing salt or potassium.
- Late pregnancy, when electrolyte levels can drop.
- Some medicines, including diuretics, some blood pressure drugs (ARBs and some beta-blockers), asthma inhalers (bronchodilators), lovastatin and birth control pills.
- Stimulants such as caffeine and nicotine, and sedatives such as alcohol.
- Less often: an underactive thyroid, nerve disorders or dialysis.
Can dehydration cause muscle cramps?
It can play a part. Muscle cramps are on the list of signs of mild to moderate dehydration. MedlinePlus, Dehydration (2025). Losing fluid through sweat, vomiting or diarrhea also takes electrolytes with it, and low electrolytes make cramps more likely. That's why doctors suggest drinking plenty of fluids after exercise, particularly sports drinks that contain potassium. MSD Manual. But most night cramps have no known cause, so water alone isn't a guaranteed fix. Electrolytes explained → Signs of dehydration →
How to stop a leg cramp
Stretch the muscle. For a calf cramp, pull your foot and toes up toward you with your hand, or stand and do a runner's stretch. Massage can also help for a while. MSD Manual. Does pickle juice stop cramps? →
How to prevent leg cramps at night
- Stretch gently before bed and before exercise. The runner's stretch is the best one for the calves: one leg forward and bent, the other straight behind, both heels on the floor, hands on a wall, then bend the front knee until you feel the stretch in the back calf.
- Drink plenty of fluids after exercise, especially sports drinks with potassium. Should you drink water before bed? →
- Cut out caffeine (coffee, chocolate) and other stimulants such as nicotine and the decongestant pseudoephedrine.
Does magnesium help leg cramps?
Probably not. Most medicines and supplements prescribed to prevent cramps, including calcium supplements and magnesium carbonate, haven't proved effective, and they can have side effects. Quinine is no longer recommended for cramps because of side effects such as abnormal heart rhythms, vomiting, vision problems, ringing in the ears and headaches. MSD Manual. If a blood test shows your magnesium or potassium is actually low, that's different: your doctor will treat it.
Leg cramps in pregnancy
Electrolyte levels can drop late in pregnancy, which makes cramps more likely. MSD Manual. Stretching usually helps; ask your doctor or midwife before taking any supplement.
When to see a doctor
- As soon as possible if cramps come with sudden weakness or loss of feeling, are severe, or follow losing a lot of fluid through vomiting, diarrhea or heavy sweating, or if you drink heavily.
- If cramps affect your arms or trunk, or come with muscle twitching: that's more likely due to an electrolyte or hormone problem, or a medicine, than to ordinary leg cramps.
- Calf pain that comes on while walking isn't a cramp; it can be poor blood flow (peripheral artery disease) and needs checking.
Questions
Why do I get leg cramps at night?
Often for no clear reason. Tight calves, low electrolytes, losing fluid, some medicines, caffeine and late pregnancy make them more likely.
Can dehydration cause leg cramps?
It can contribute: muscle cramps are a sign of mild to moderate dehydration, and losing fluid also means losing electrolytes. Drinking enough, especially after exercise, helps.
What stops a leg cramp fast?
Stretching the muscle: pull your foot and toes toward you, or stand and do a runner's stretch. Massage can help too.
Does magnesium stop leg cramps?
Supplements like magnesium carbonate haven't proved effective for preventing cramps, unless a test shows your magnesium is low.
Are leg cramps a sign of something serious?
Usually not. See a doctor if they come with weakness, numbness, twitching, cramps in the arms or trunk, or after heavy fluid loss.
Sources
- MSD Manual, Consumer Version: Muscle cramps (M. Freedman, 2025)
- MedlinePlus, Dehydration (reviewed 2025)
General information, not medical advice. Cramps with sudden weakness, numbness, or after heavy vomiting, diarrhea or sweating need a doctor. Don't stop a prescribed medicine without asking.
