9 Causes of Leg Cramps—and How To Stop Them

7 minute read

What are leg cramps?

If you haven’t already, you will probably experience leg cramps at some point in your life. They can hit at the worst possible moments; whether you’re lying in bed at night or taking a run on the treadmill, that sharp stabbing pain can feel totally debilitating. If leg cramps, also called charley horses, persist, they can become even more irritating, perhaps knocking you off your typical exercise or sleep routine.

A leg cramp is a sharp, sudden contraction or tightening of the muscle in the calf, which usually lasts a few seconds to a few minutes. If a cramp does hit, you can ease it in the moment by stretching the muscle gently. To find a long-term solution to leg cramps, however, you might need to take a closer look at their many potential causes.

To keep leg cramps at bay, make sure you’re nourishing your body and getting enough rest. You’ll also want to rule out any underlying issues that could be contributing to leg cramping, such as peripheral artery disease or thyroid issues. See a doctor when cramps prevent you from exercising, or if they seem to happen spontaneously without a trigger.

Here, experts weigh in on the major reasons you might be experiencing leg cramps, so you can keep those muscles free of charley horses for good.

Dehydration

One of the classic causes of leg cramps is dehydration. “Athletes and avid exercisers deal with cramps all the time,” says Mark D. Peterson, PhD, research assistant professor in the department of physical medicine and rehabilitation at the University of Michigan Medical School, “especially during the summer months, in the heat without enough liquid.” The reason dehydration causes cramping is largely theoretical, says Todd J. Sontag, DO, family physician with Orlando Health Physician Associates. It may be that fluid depletion causes nerve endings to become sensitized, “triggering contractions in the space around the nerve and increasing pressure on motor nerve endings,” he says. This depletion is exacerbated by hot conditions or exercising, since you lose more fluid through sweat.

Health.com: 14 Surprising Causes of Dehydration

Mineral deficiency

It’s not just water that you sweat out. Lost electrolytes can also contribute to leg cramping. If you’re low in certain electrolytes and other minerals, that imbalance can trigger spontaneous cramping. An imbalance in sodium, calcium, magnesium, or potassium could all lead to leg cramping, says Gerardo Miranda-Comas, MD, associate program director of the sports medicine fellowship at the Icahn School of Medicine at Mount Sinai. Sports drinks can help reduce cramps thanks to their sodium, as can eating wisely. Bananas, sweet potatoes, spinach, yogurt, and nuts are rich in those muscle-friendly minerals and may ward off the deficiencies that could cause leg cramps.

Pregnancy

Pregnancy increases a woman’s risk for leg cramps, especially during the second and third trimesters. “This is most likely because the odds of magnesium and potassium deficiency are higher during pregnancy,” Peterson says. If you’re pregnant and experiencing leg cramps, stay hydrated and consider taking a magnesium supplement–with your doctor’s approval.

Overuse

Independent of an exerciser’s hydration status, many experience leg cramping due to overuse. “If you’re going on a long run, or you’re doing a boot camp, you might experience cramping later on,” Peterson says. “The nervous system is usually the culprit.” When the nerves running from the brain and spinal cord down to the muscle become overexcited, you often wind up with an involuntary cramp. Rest and stretching is extra important in these situations.

Exercise intensity

When you’re trying to kick your routine up a notch–increasing your biking mileage, starting to swim for triathlon training–your muscles aren’t automatically used to the new intensity and movement. “Whenever cramps are induced by starting or restarting an exercise, that’s usually an indication of ‘too much, too soon,'” Dr. Miranda-Comas explains. “Your muscles don’t act and respond the same when you jog and sprint, for instance, so any increase in workout volume or intensity can trigger cramps.”

Fatigue

You may be more prone to leg cramps when you’re already overtired. You might be more lax in your diet or forget to hydrate effectively, or, if your body hasn’t had enough time to properly recover from your last bout of exercise, your muscles might already be in rough shape. “Physiologically, when the muscle is fatigued, it’s not as synchronized in using nutrients,” Dr. Miranda-Comas says. In other words, a tired muscle loses more nutrients than it uses, so it’s not functioning at its peak. Nighttime or nocturnal leg cramps, which affect more than half of adults, can also be triggered by tiredness. “Although there is no one definitive cause [of nighttime leg cramps], they are likely associated with muscle fatigue and nerve dysfunction,” Dr. Sontag explains. “There’s also new research to suggest athletes that underwent higher-than-normal-intensity exercise had an increase in the incidence of nocturnal leg cramps.”

Health.com: 14 Reasons You’re Always Tired

Sitting or standing

Muscles were made to move, contract, and rest, so if you’re doing anything out of the ordinary–sitting at a conference all day, standing in line at an amusement park–you might experience some leg cramping. Standing for a prolonged period of time can understandably contribute to muscle fatigue, which in turn can cause cramping, Dr. Sontag says. But too much sitting isn’t necessarily better. Prolonged sitting “may predispose the muscles to malfunction,” he explains, as the muscle fibers may become hyperactive. When the muscle is “on” and can’t relax, you end up getting a cramp. If you get leg cramps from standing, make sure to take a seat before your muscles feel too tired. And if you cramp from sitting for long periods of time, try to spend at least a couple of minutes walking around per hour that you’re seated.

Medications

If there’s no obvious cause of your leg cramps, then you might want to take a look at any recent additions to your medication list, Dr. Sontag says. Diuretics, a class of medications used to lower blood pressure, may trigger cramps because they deplete the body of fluid and salts, he explains. Other medications that may cause leg cramps include osteoporosis drugs like raloxifene and teriparatide; intravenous iron sucrose (used to treat anemia); asthma medications like albuterol; conjugated estrogens (used to treat menopausesymptoms); and pain meds like naproxen and pregabalin. Commonly prescribed statins are also associated with muscle cramps in general, he adds. Talk to your doctor if you started taking a new medication at the onset of your leg cramps; Dr. Sontag says he is usually able to find an alternative medication for his patients.

Medical conditions

If your leg cramps seem spontaneous and not exercise-related, it’s important to see your doctor to rule out underlying concerns. Some, for instance, “those that affect how the body moves electrolytes,” Dr. Miranda-Comas says, can cause leg cramps. Others, like peripheral artery disease, affect blood flow, which can in turn trigger cramps since there may not be enough blood getting to the legs. Osteoarthritis, neuropathy, and thyroid conditions may also contribute to leg cramps, Dr. Sontag says. Always check with a doctor if you have unresolved cramping, especially with adequate nutrition, hydration, and stretching.

This article originally appeared on Health.com

More Must-Reads From TIME

Contact us at letters@time.com