You’re midway through a run, workout, or CrossFit session when suddenly it strikes—a debilitating muscle cramp that stops you cold. Nothing kills a workout quite like the pain and tightness a cramp brings on. And whether you’re lifting weights, running sprints, or doing laps in the pool, you can cramp up. “A cramp is when the muscle unit itself contracts and doesn’t have enough resources to release that contraction,” explains Jennifer J. Beck, M.D., an assistant professor of orthopedic surgery at UCLA’s Orthopedic Institute for Children. Muscle cramps typically strike whatever area you’re working the hardest. “Runners are likely to get lower-extremity cramps, while rowers and swimmers might be more prone to upper-extremity and chest-wall cramps,” Beck says.


It’s not just the movement that’s to blame. “The most common cause of muscle cramps tends to be something nutritional,” says Jordan D. Metzl, M.D., a sports medicine physician at the Hospital for Special Surgery in New York. That’s especially true for endurance athletes like distance runners, cyclists, and triathletes, who have lost high amounts of electrolytes through their sweat without replacing them. This can lead to a deficiency in sodium levels, which triggers cramps.

“In order to combat these deficiencies you need to make sure you’re being nutritionally smart,” says Metzl. That means getting enough electrolytes in your diet with salty foods like pretzels or taking salt tablets during workouts. In addition to sodium, the minerals potassium, magnesium, and calcium can help prevent your muscles from locking up. Aim to get these nutrients through foods first, advises Beck.

Key sources include bananas for potassium, leafy green vegetables for magnesium, and diary products like milk and yogurt for calcium. Proper hydration is also important, since dehydration causes an alteration in electrolyte concentration as well as a buildup of lactic acid from muscle metabolism, both of which can cause cramps. Individual needs vary—some people do fine with just a little water, others require more fluids or a sports drink with electrolytes. “Experiment to see what works best for you,” says Beck.


Cramping can also occur when your workouts get the best of you. “Functional cramps happen in people who overload their muscular capacity,” says Metzl. That can mean putting too much weight on the bar, maxing out on the number of reps you’re doing, or even putting your body in a position where flexibility is an issue.

To help keep muscles mobile, incorporate more flexibility in your training. It can also help to use a foam roller before a workout, adds Metzl. Sudden and intense movements, such as sprint intervals, may be another cramp trigger. That’s especially true if you haven’t properly warmed up, stretched, or prepared your body for action. “If you’re going to recruit all the energy required of your hamstrings and quad muscles to do something like sprint 400 meters but your muscles don’t have the energy or building blocks to do so, they will most likely cramp up,” explains Beck. Improving your flexibility can go a long way toward keeping your muscles limber and less likely to cramp.