Tips to prevent nighttime leg cramps
You’re just drifting off — or maybe you’re already asleep — when a sudden, sharp cramp in your calf jolts you awake.
Nighttime leg cramps are common and can make it hard to fall or stay asleep. But there’s good news: There are things you can do to prevent or reduce leg cramps.
Why leg cramps happen
A leg cramp is a sudden, painful tightening of muscle, usually in the calf. It can last a few seconds or several minutes. The pain can continue even after the muscle relaxes.
It’s not always easy to identify the exact cause of a leg cramp, but common triggers include:
- Tired or overworked muscles due to exercise or a long day of exertion
- Not getting enough fluids (dehydration)
- Low levels of certain nutrients, such as potassium or magnesium
- Muscle stiffness from sitting or lying in one position too long
Certain health conditions, such as diabetes, nerve issues or sleep apnea and some medicines, also can increase your risk.
How to prevent leg cramps
If leg cramps are affecting your sleep, these small habits can help:
Move and stretch your legs before bed. Sitting or lying still for long periods can make muscles more likely to cramp. A few minutes of gentle movement and stretching can help your muscles relax before you lie down.
Take a short walk or bike ride in the evening.
Lightly massage any tight areas.
Stay hydrated during the day. Muscles need fluids to work properly. If you sweat a lot or exercise frequently — especially in the heat — drink more water than usual, and consider adding an electrolyte powder or drink. Avoid alcohol and caffeine, since both are diuretics.
Adjust your bed covers. Avoid tightly tucked blankets that push your toes down. Instead, loosen the sheets and covers at the foot of your bed.
Eat a healthy diet. Low levels of some minerals and vitamins can cause cramps. Include these in your diet:
- Potassium: Bananas, potatoes and oranges are good sources.
- Magnesium: Nuts, seeds and leafy greens can boost magnesium. Powdered supplements are also available.
- Vitamin D: Fatty fish — such as trout, salmon and tuna — is rich in vitamin D. It’s also found in fortified foods like dairy milk, plant milk and breakfast cereal. Many people take vitamin D supplements.
- B vitamins: B vitamins are found in a variety of vegetables, eggs, fish, meats, dairy products, nuts and legumes. They’re also in fortified foods such as breakfast cereals and grains.
- Vitamin K: Early research suggests that vitamin K may reduce leg cramps. Good sources include green leafy vegetables like spinach and broccoli. Vitamin K also is found in vegetable oils, including soybean, canola and olive oils.
Know your medicines. Some medicines can make cramps more likely, including:
- Some blood pressure medicines. Cramps are especially common with water pills, also called diuretics.
- Statins. Statins help manage cholesterol and reduce the risk of heart attack and stroke.
- Long-acting beta agonists. This type of medicine is used to treat asthma, COPD and other breathing conditions
- Certain osteoporosis medicines used to treat bone thinning
If leg cramps are new or getting worse, ask your pharmacist or care team to review your medicines. Team members may be able to make adjustments that help. Don’t stop taking prescribed medicines on your own.
When a cramp wakes you up
If you get a leg cramp in the middle of the night:
- Gently stretch the muscle by pulling your foot up toward your face.
- Massage the area gently. Try using ice.
- Walk around the room or shake your leg.
- Soak in a warm bath. Or take a hot shower and direct the water to the cramped muscle.
Leg cramps are usually harmless and don’t need medical care. However, you should talk to your healthcare team if:
- Cramps are affecting your daily life and aren’t getting better with these at-home remedies
- Cramps are regularly disrupting your sleep
- Your leg is swollen, warm or changing color. Reach out to your care team right away if you notice these changes.
In some cases, cramps can be linked to an underlying condition, such as restless legs syndrome, obstructive sleep apnea, diabetes or Parkinson’s disease. Treating the condition can improve your symptoms and your sleep.
© 2026 Mayo Foundation for Medical Education and Research. All rights reserved. Distributed by Tribune Content Agency LLC.