The dreaded charley horse: No one really knows how it got its name, but up to 60 percent of adults experience the occasional nocturnal leg cramp, which can feel like a painful spasm, tightening, or twinge.  

Charley horses develop when the nerves that carry signals to your muscles fire off too many messages at once. This causes your muscles to contract in an uncomfortable way, notes Scott Garrison, MD, PhD, director of the department of family medicine at the University of Alberta.

Sitting or lying down for a long time—like when you're sleeping—can trigger the nerve malfunction. That's why you tend to get cramps in the middle of the night. And you know: If you're lying awake thanks to a charley horse, you’re losing the sleep you need to crush your morning ride.

More From Bicycling
 
preview for HDM All Sections Playlist - Bicycling

     RELATED: 9 Foods To Help You Sleep Better

Weirdly enough, charley horses are more common in warmer months, according to a new study by Garrison and his team. It might be because you have higher levels of vitamin D, thanks to increased sun exposure on long summer rides. "The nutrient plays a role in regulating the growth and repair of your muscle fibers," says Garrison. "But more growth and repair may also send the muscle mechanism behind your cramps into overdrive."

According to Garrison, charley horses become more common—and painful—as you age. After you hit 50, you start losing more of the nerve cells that send messages from your brain to your muscles. The cells that are left have to work harder, which experts speculate might cause cramping.  

     RELATED: 7 Crazy Things That Happen While You Sleep

Fortunately, the spasms are usually harmless. But in rare cases, they can signal electrolyte imbalance or neuromuscular disorders like amyotrophic lateral sclerosis (ALS), known as Lou Gehrig's disease.

So what can you do to help prevent charley horses? Stretching your calves, hamstrings, and quads before bed will stop cramps before they start while also preventing soreness and increasing flexibility for your training. In fact, a 2012 study from the Netherlands found that older adults who suffered from charley horses experienced fewer, less severe spasms when they stretched their legs for three minutes prior to hitting the sack.

Target these areas with The Best Stretch for Every Body Part

If a spasm does strike in the middle of the night, ease the pain by using the same stretches.

Your usual first line of defense—hopping out of bed and walking around for a minute—will help relieve tightness, too.

This article originally appeared on Men's Health.

Headshot of Marygrace Taylor
Marygrace Taylor
Marygrace Taylor is a health and wellness writer for Prevention, Parade, Women’s Health, Redbook, and others. She’s also the co-author of Prevention’s Eat Clean, Stay Lean: The Diet and Prevention’s Mediterranean Kitchen. Visit her at marygracetaylor.com.