Nighttime cramps are sudden, involuntary and often very painful muscle contractions that occur during the night. Although generally harmless, these muscle spasms can disrupt your sleep, affect physical recovery and reduce your quality of life. Understanding their causes and prevention strategies may help reduce how often they occur and how severe they are.
What is a nighttime cramp?
A nighttime cramp is a brief, involuntary muscle contraction that occurs during sleep. Unlike muscle cramps associated with exertion, which occur during physical activity, nighttime cramps interrupt rest and can last from a few seconds to several minutes.
They often come on suddenly, waking you immediately and causing pain in a specific area. In some cases, they leave a lingering feeling of tightness or muscle discomfort that persists after you wake up.
Areas most affected: calf, foot, thigh
The muscle groups most often affected by nighttime cramps are the calf muscles (particularly the triceps surae), the muscles in the sole of the foot and the hamstrings at the back of the thigh. Used throughout the day, they may contract involuntarily at night, particularly when held in a shortened position.
The pain in the legs can be intense, sometimes throbbing, and accompanied by prolonged muscle stiffness. For some people, discomfort can persist for several hours after the cramp, affecting movement in the morning and overall comfort.
Nighttime cramps: who is affected?
Nighttime muscle cramps can affect anyone, but some people are at greater risk than others. They are common among:
- older adults (over 60), due to reduced muscle mass and changes in how water is distributed throughout the body.
- pregnant women, especially in the third trimester.
- athletes who train intensely, exercise for prolonged periods or do not get enough recovery time.
-
people with chronic conditions (diabetes, kidney failure, neurological disorders…).
What causes nighttime cramps?

Muscle fatigue and intense exercise
Unusual physical exertion, intensive training, standing for long periods or activities that repeatedly use the same muscle groups (gardening, hiking, climbing stairs...) can overload the muscles. This can contribute to cramps through increased neuromuscular activity, particularly during rest.
Poor sleeping positions
Sleeping in a position that keeps your toes pointed or your legs bent for a long time can shorten certain muscles, especially the calf muscles. This shortening makes a reflex muscle contraction more likely, which can then cause a cramp.
Dehydration and electrolyte imbalances
Dehydration, even mild dehydration, disrupts the balance of sodium, potassium, calcium and magnesium. These electrolytes are essential for nerve impulse transmission and muscle relaxation. A lack of water affects their distribution within cells and increases the reactivity of muscle fibers.
Mineral deficiencies
An insufficient intake of magnesium, calcium or potassium can increase muscle excitability. These minerals play a role in muscle relaxation and the stability of cell membranes. Even a mild deficiency can cause neuromuscular symptoms such as cramps.
Medications and medical treatments
Some medications are associated with an increased risk of nighttime cramps. These include:
- Diuretics, which increase the loss of potassium and magnesium through urine.
- Statins, which are sometimes linked to muscle problems.
-
Antipsychotics, corticosteroids or beta blockers.
It is important to tell your doctor about these effects, especially if the cramps begin after you start a new medication.
Associated medical conditions
Certain chronic conditions can make cramps more likely, including diabetes, chronic kidney failure, thyroid disorders, neuromuscular conditions and peripheral neuropathies. People with these conditions need a thorough assessment, including blood tests and sometimes an electromyogram.
When should you consult a healthcare professional?
Nighttime cramps require medical advice when they become frequent, severe or disabling. You should consult a doctor if:
- they occur more than 3 times a week,
- they disrupt your sleep significantly,
- you have associated symptoms (numbness, loss of strength, widespread pain),
- If you have recently started taking medication.
A doctor may order further tests and recommend targeted treatment based on the suspected cause.
What should you do if you get a nighttime cramp?
When a cramp strikes in the middle of the night, the immediate goal is to relax the contracted muscle and relieve the pain. The most effective approach is to stretch the muscle slowly without forcing it.
For a calf cramp, for example, straighten your leg and gently pull your toes toward you, holding the stretch for 10 to 15 seconds. This helps restore the muscle’s length and stop the contraction.
Gently massaging the area in circular motions also helps relieve tension. Heat (a hot water bottle or warm shower) promotes vasodilation and oxygen delivery to the muscles. These natural remedies are often enough to ease the pain.
Drinking fluids promptly is recommended, particularly after heavy sweating due to exercise or heat. Drinking a beverage containing minerals helps restore fluid balance and support muscle recovery. Even moderate electrolyte loss can contribute to repeated painful contractions, making it important to replenish fluids and minerals gradually toward the end of the day.
How can you prevent nighttime cramps?
Daily stretching
Adding gentle stretches to your evening routine improves muscle flexibility and limits reflex contractions. Focus on stretching your calves, hamstrings and the muscles in the soles of your feet. These simple steps improve mobility and help prevent cramps.
Yoga, swimming or brisk walking also help maintain muscle health and prevent tension from building up throughout the day.
Appropriate physical activity
Regular physical activity that is not excessive reduces chronic muscle tension. Exercise improves blood flow, reduces inflammation and supports neuromuscular balance. It is important to adjust the intensity of your exercise to your fitness level and allow time for recovery.
Balanced diet
Your diet should provide enough of the following:
- Magnesium: almonds, lentils, dark chocolate, whole grains
- Potassium : bananas, sweet potatoes, avocado, spinach
-
Calcium: dairy products, sardines, tofu, green vegetables
These nutrients play a fundamental role in muscle function. A chronic deficiency increases the risk of involuntary contractions, particularly at night.
Hydration

Drinking enough throughout the day helps maintain proper nerve impulse conduction. During exercise, in hot weather or when sweating heavily, water alone may not be enough. Adding sodium, potassium and glucose to a drink helps the body absorb water into muscle cells.
Chronic dehydration, even when mild, can contribute to electrolyte imbalances, particularly in the fluid between cells. This may increase the excitability of muscle fibers.
Supplements
If a blood test confirms a deficiency, magnesium, potassium or calcium supplements may be recommended. These should only be taken on medical advice, especially by people with kidney failure or high blood pressure.
Frequently asked questions
What should you drink to help prevent cramps?
Magnesium-rich mineral water or an electrolyte drink containing sodium and potassium may help prevent cramps, especially during exercise or in hot weather.
Which deficiencies cause cramps?
The main deficiencies involved are magnesium, calcium and potassium deficiencies. They affect neuromuscular signaling and the muscle’s ability to relax properly.
What medical conditions can cause cramps?
Conditions such as diabetes, hypothyroidism, neuromuscular disorders or neuropathies can cause frequent cramps. A medical assessment is needed.
How can you prevent cramps at night?
Make stretching part of your routine, eat a mineral-rich diet, drink regularly and seek medical advice if the episodes become recurrent.
Sources
Allen, R. E., & Kirby, K. A. (2012). Nocturnal leg cramps. American Family Physician, 86(4), 350–355.
Hallegraeff, J. et al. (2017). Criteria in diagnosing nocturnal leg cramps: a systematic review. BMC Family Practice, 18(1), 29. https://doi.org/10.1186/s12875-017-0600-x