Leg cramps at night don’t always have a medical cause, but it’s a good idea to see a doctor to rule this out. To help prevent them, stretch your calf and hamstring muscles before bed.

Imagine you’re lying down, and your lower leg seizes. The pain is intense enough to make you want to scream. It doesn’t let up, and your muscle is hard to the touch. When you try to move your leg, it feels paralyzed. Sound familiar?

According to American Family Physician, nocturnal leg cramps affect up to 60 percent of adults. Sometimes referred to as muscle spasms or charley horses, they occur when one or more of the muscles in the leg tighten involuntarily.

Leg cramps most often affect the gastrocnemius muscle (calf muscle) which spans the back of each leg from the ankle to the knee. However, they can also affect the muscles at the front of each thigh (quadriceps) and the back of each thigh (hamstrings).

You can be awake or asleep when a leg cramp strikes. Most of the time, the muscle relaxes itself in less than 10 minutes. Your leg might feel sore or tender for up to a day afterward. Frequent calf cramps at night can disrupt your sleep.

Leg cramps during sleep are more common among women and older adults.

Experts don’t know exactly what causes leg cramps at night. There are, however, known factors that can increase your risk. In most cases, nocturnal leg cramps are idiopathic, which means their exact cause isn’t known.

Nighttime leg cramps may be related to foot position. We often sleep with our feet and toes extending away from the rest of our bodies, a position called plantar flexion. This shortens the calf muscles, making them more susceptible to cramping.

Other factors that may contribute to nighttime leg cramps include:

  • Sedentary lifestyle. Muscles need to be stretched regularly to function properly. Sitting for long periods of time could make leg muscles more susceptible to cramping.
  • Muscle overexertion. Too much exercise can create an overworked muscle and may be associated with muscle cramps.
  • Improper sitting position. Sitting with your legs crossed or your toes pointed for long periods of time shortens the calf muscles, which could lead to cramping.
  • Prolonged standing. Research suggests that people who stand for long periods of time at work are more likely to experience nocturnal leg cramps.
  • Abnormal nerve activity. According to electromyographic studies, leg cramps are associated with increased, abnormal nerve firing.
  • Shortening of the tendons. The tendons, which connect muscles and bones, shorten naturally over time. This could lead to cramping in the muscles.

Leg cramps at night are unlikely to be the first sign of a more serious medical condition. They are, however, associated with the following conditions:

Though leg cramps at night can be intensely painful, they aren’t typically serious. Most people who experience them don’t need medical treatment.

You can try the following at home to try to relieve a cramp:

  • Massage your leg. Rubbing the affected muscle may help it relax. Use one or both hands to gently knead and loosen the muscle.
  • Stretch. If the cramp is in your calf, straighten your leg. Flex your foot so that it’s lifted to face you and your toes are pointing towards you.
  • Walk on your heels. This will activate the muscles opposite your calf, allowing it to relax.
  • Apply heat. Heat can soothe tight muscles. Apply a hot towel, hot water bottle, or heating pad to the affected area. Taking a warm bath or shower may also help.
  • Drink pickle juice. Some evidence suggests that drinking a small amount of pickle juice may help relieve muscle cramps.
  • Take an over-the-counter painkiller if your leg is sore after. Nonsteroidal anti-inflammatory (NSAID) drugs such as ibuprofen (Advil, Motrin) and naproxen (Aleve) can help relieve tenderness after a cramp. Acetaminophen (Tylenol) can work as well.

If frequent cramps are disrupting your sleep, make an appointment with your doctor. They might prescribe a muscle relaxant to prevent cramps. If your cramps are related to another medical condition, they can help manage that too.

The following tips may help you avoid leg cramps while sleeping:

  • Drink plenty of fluids. Fluids allow for normal muscle function. You might need to adjust how much fluid you drink based on factors such as the weather, your age, activity level, and medication you’re taking.
  • Stretch your legs. Stretching your calves and hamstrings before bed can reduce the frequency and severity of nocturnal leg cramps.
  • Ride a stationary bike. A few minutes of easy pedaling might help loosen up your leg muscles before you go to sleep.
  • Change your sleeping position. You should avoid sleeping in positions in which your feet are pointing downward. Try sleeping on your back with a pillow behind your knees.
  • Avoid heavy or tucked-in bedding. Heavy or tucked-in bedding could push your feet downward while you sleep. Choose loose, untucked sheets, and a comforter that will allow you to keep your feet and toes upright while you sleep.
  • Choose supportive footwear. Poor footwear can aggravate issues with the nerves and muscles in your feet and legs, especially if you have flat feet.

If you’ve ever experienced leg cramps at night, you know how painful they can be. Fortunately, they’re usually not a sign of a serious problem. Stretching the calf and hamstring muscles before bed may help to prevent nocturnal leg cramps.