One possible cause is dehydration. When the body lacks enough fluids, muscles may become more sensitive and prone to spasms. Not drinking enough water during the day, especially in hot weather or after exercise, can increase the risk of nighttime cramps.
Mineral imbalances may also play a role. Low levels of magnesium, potassium, or calcium can affect normal muscle function and trigger painful contractions. Poor diet, excessive sweating, or certain medications may contribute to these deficiencies.