The exact cause of nocturnal leg cramps is unknown. However, the Cleveland Clinic reports, some cases have been traced to everyday home and workplace hazards, such as overworking the muscles, sitting for too long or in an improper position, and standing or walking on hard concrete floors.
Nocturnal leg cramps have been linked to a number of medical conditions, including alcoholism, dehydration, Parkinson's disease or pregnancy. Commonly prescribed medications such as beta agonists, diuretics and statins have been implicated as well. Flat feet may contribute to the problem, as may endocrine or neuromuscular system disorders, per the Cleveland Clinic.
When a nocturnal leg cramp or charley horse strikes, WebMD recommends stretching and massaging the affected muscle, applying an insulated ice pack, or taking a hot bath or shower. Drinking a beverage with electrolytes such as Gatorade may also help stop the muscle contraction. Proactive measures that may prevent cramping include stretching daily, eating a balanced diet, taking a multivitamin, drinking plenty of water, and avoiding alcohol. People working to increase their physical activity should do so gradually to prevent pain at night. If bedtime pain is recurrent and accompanied by an urge to move the limbs, a doctor may need to rule out restless leg syndrome, according to the National Heart, Lung and Blood Institute.