Muscle cramps: why they happen and how to stop them
A sudden calf cramp can stop you in your tracks. Here is what causes muscle cramps, what to do when one hits and simple steps to make them less likely, including fluids, stretching and food.

You are in bed, you stretch your leg and suddenly your calf locks up in a hard, painful knot. Or you are out for a run in the heat and your thigh seizes. Muscle cramps are common, and they can really hurt.
Most cramps are harmless and pass in a few minutes. Here is what causes them, what to do when one strikes and how to lower your chances of the next one, based on MedlinePlus.
- A muscle cramp is when a muscle tightens on its own and will not relax.
- The calf, the back of the thigh and the front of the thigh are the most common spots.
- Overuse, injury and exercising while low on fluids or minerals make cramps more likely.
- When a cramp hits, stop, then stretch and massage the muscle.
- Drinking fluids, regular stretching and eating potassium rich foods may help prevent cramps.
- Call your doctor if cramps are severe, keep coming back or do not get better with stretching.
What a muscle cramp is
MedlinePlus says a muscle cramp happens when a muscle gets tight, or contracts, without you trying to tighten it, and it does not relax. Cramps can involve part or all of a muscle, or a few muscles in a group.
The most common spots, according to MedlinePlus, are:
- The calf, in the back of the lower leg
- The hamstrings, in the back of the thigh
- The quadriceps, in the front of the thigh
Cramps can also happen in the feet, hands, arms and belly.
What causes muscle cramps
MedlinePlus lists these common causes:
| Cause | Examples |
|---|---|
| Overuse or injury | A long or hard workout, or a strained muscle |
| Low fluids | Exercising while dehydrated |
| Low minerals | Low levels of sodium, potassium or calcium |
| Health conditions | Low thyroid, kidney failure, alcohol use disorder |
| Life stages | Pregnancy and periods |
| Medicines | Some medicines can cause cramps as a side effect |
MedlinePlus says dehydration is the most common cause of cramps during sports. Hot, humid weather makes it easier to lose fluids and minerals through sweat.
What to do when a cramp hits
MedlinePlus suggests these steps:
- Stop what you are doing.
- Stretch the muscle. For a calf cramp, straighten your leg and gently pull your toes up toward your shin.
- Massage the muscle. Rub it with your hands.
- Use heat to relax it. A warm towel or heating pad can help a tight muscle let go.
- Use ice once the pain eases. This can help with soreness.
- Drink fluids if you have been sweating.
MedlinePlus also says anti inflammatory pain relievers can help if the muscle stays sore. For severe cramps, a doctor may prescribe other medicine.
Simple stretches for common cramps
| Muscle | Stretch |
|---|---|
| Calf | Stand facing a wall, step one foot back and press the heel down |
| Back of thigh | Sit with your leg straight and reach gently toward your toes |
| Front of thigh | Hold a chair, bend your knee and bring your heel toward your bottom |
| Foot | Pull your toes back toward your shin, or stand and press your toes into the floor |
Our post on hamstring stretches walks through more ways to stretch the back of your thigh.
How to prevent cramps
MedlinePlus shares these steps:
- Exercise within your ability. Build up slowly instead of jumping into long, hard workouts.
- Drink plenty of fluids while you are active, especially in the heat.
- Replace minerals when you sweat a lot. MedlinePlus says water alone does not always do it. Sports drinks that replace lost minerals can help during long, sweaty workouts.
- Eat potassium rich foods, like oranges and bananas.
- Stretch regularly to improve flexibility.
Our posts on sports drinks or water and signs of dehydration can help you stay ahead of fluid loss.
Foods that help
MedlinePlus mentions oranges and bananas. The NIH Office of Dietary Supplements lists many other foods that are good sources of potassium, like potatoes, beans, lentils, milk and yogurt. Our full guide to potassium foods lists the best ones.
| Food | Why it helps |
|---|---|
| Bananas and oranges | Potassium, named by MedlinePlus |
| Potatoes and sweet potatoes | Potassium |
| Beans and lentils | Potassium |
| Yogurt and milk | Potassium |
| Watery fruits like melon | Fluids. See our post on hydrating foods. |
A simple routine before you work out
Mayo Clinic suggests warming up for 5 to 10 minutes before exercise and cooling down after. Putting that together with the MedlinePlus tips, a cramp friendly routine could look like this:
- Drink a glass of water before you head out, and bring water with you.
- Warm up with easy walking or slow movement.
- Do your workout at a level you can handle, and build up slowly over weeks.
- Cool down with a slow walk.
- Stretch your calves and thighs once your muscles are warm.
Our post on warm ups and cool downs has more detail.
Night leg cramps
Cramps at night can wake you from sleep. Stretching your calves before bed may help, since regular stretching improves flexibility. If the urge to move your legs at night feels more like crawling or tingling than a hard knot, it may be restless legs instead. Our post on restless legs explains the difference.
When to call your doctor
MedlinePlus says to contact your doctor if cramps:
- Are severe
- Do not get better with stretching
- Keep coming back
- Last a long time
Also tell your doctor if you think a medicine is causing cramps. Do not stop taking a medicine on your own.
FAQ
Do bananas stop cramps?
MedlinePlus says potassium rich foods like bananas and oranges may help prevent cramps. They are not a quick fix once a cramp starts.
Why do I get cramps when I exercise?
Overuse and dehydration are common causes. MedlinePlus says dehydration is the most common cause of cramps during sports.
Should I use heat or ice?
MedlinePlus says heat can relax a cramping muscle, and ice may help once the pain eases.
Can pregnancy cause leg cramps?
Yes. MedlinePlus lists pregnancy as one possible cause.
For more simple, science based tips, get our free 7 day gut reset.
Sources: MedlinePlus, Muscle cramps. MedlinePlus, Dehydration. NIH Office of Dietary Supplements, Potassium fact sheet. Mayo Clinic, Aerobic exercise: How to warm up and cool down.
Get new posts by email.
Pick a short weekly email, or one calm digest a month.
