To stop a muscle cramp in progress, firmly stretch the cramping muscle and hold that stretch until the contraction releases, usually within 30 to 90 seconds. If the cramp is in your calf (the most common location), pull your toes and foot upward toward your shin, either with your hand or by standing and pressing your heel into the floor. For a thigh cramp, straighten your leg and pull your foot toward your buttock if the front of the thigh is affected, or extend the leg fully if the back is cramping.
That handles the immediate crisis. But if you’re dealing with cramps regularly, during exercise or in the middle of the night, understanding why they happen opens up better ways to prevent them.
Why Muscles Cramp in the First Place
A muscle cramp is an involuntary contraction that refuses to let go. The problem starts at the point where nerves connect to muscle fibers. When that junction becomes hyperexcitable, whether from electrolyte shifts, fatigue, or nerve irritation, the signals telling your muscle to contract fire uncontrollably. Your spinal cord can amplify those signals further, turning a small twitch into a full, painful lockup.
This is why cramps tend to strike when muscles are already shortened, fatigued, or depleted. A tired calf muscle while running, or a foot that’s been pointed downward in bed for hours, is primed for that runaway nerve firing.
What to Do During a Cramp
Stretching works because it mechanically lengthens the muscle and interrupts the contraction loop. But you can pair it with a few other techniques for faster relief:
- Stretch and hold. Gently pull the muscle into a lengthened position and hold for 30 seconds or more. Don’t bounce. For a calf cramp, flex your foot so your toes point toward your knee. For a hamstring cramp, straighten your leg completely.
- Walk on it. If the cramp is in your lower leg, standing up and putting weight on the affected leg can help override the contraction. Walk slowly on your heels if you can.
- Massage the muscle. Press into the belly of the cramping muscle with your thumbs or knuckles while it’s being stretched. This stimulates blood flow and may help the nerve signals settle down.
- Apply heat. A warm towel or heating pad on the cramped muscle reduces spasm and stiffness. Johns Hopkins Medicine notes that heat is useful specifically when muscles are tight. Save ice for after the cramp resolves, if the area feels sore or inflamed.
The Pickle Juice Trick
Drinking a small amount of pickle juice (about 1 to 2 ounces) can stop a cramp surprisingly fast. The mechanism has nothing to do with hydration or replacing salt. The acid in the brine triggers nerves in the back of the throat, which send a signal down through the spinal cord that essentially tells the cramping muscle to shut off. Researchers at Michigan Medicine confirmed it’s this throat reflex, not the sodium content, that does the work. Any strongly acidic liquid, like vinegar diluted in water, appears to have a similar effect.
Sodium and Sweat: The Exercise Connection
If your cramps happen during or after hard exercise, especially in heat, sodium loss is likely a major factor. A study of NCAA football players found that athletes who were prone to cramping lost twice the sodium in their sweat compared to teammates who didn’t cramp. Cramp-prone players averaged about 5 grams of sodium lost per session versus 2.2 grams for non-crampers. Their sweat sodium concentration was also roughly double.
This matters because sodium helps maintain the fluid balance around your muscle and nerve cells. When that balance shifts too far, nerves become more excitable and cramps follow. Plain water alone doesn’t fix this. If you’re a heavy sweater or your sweat stings your eyes and tastes salty, adding an electrolyte drink or salted snack before and during exercise can make a real difference. Sports drinks with at least 300 to 500 milligrams of sodium per serving are a reasonable starting point for long or intense workouts.
Does Magnesium Actually Help?
Magnesium supplements are one of the most commonly recommended remedies for cramps, but the clinical evidence is weak. A randomized trial of 94 adults who experienced frequent nighttime leg cramps found that magnesium oxide reduced cramp frequency by about 3.4 episodes per week, but placebo reduced it by 3.0 episodes per week. That difference was not statistically significant. There were also no differences in cramp severity, duration, sleep quality, or quality of life between the two groups.
A systematic review reached the same conclusion: magnesium supplementation is unlikely to provide meaningful cramp prevention in older adults with skeletal muscle cramps. If you’re genuinely magnesium-deficient (which blood tests can confirm), supplementation may help for other reasons. But for most people with occasional cramps, it’s probably not the fix.
Preventing Night Cramps
Nocturnal leg cramps are extremely common, especially after age 50, and they often hit the calves or the arches of the feet. The position of your feet during sleep plays a role. When you sleep with your feet pointed downward (plantar flexion), your calf muscles are shortened for hours, making them more susceptible to spontaneous contraction.
Cleveland Clinic recommends a simple stretching routine before bed: stand about 3 feet from a wall, lean forward with your arms outstretched touching the wall, and keep your feet flat on the floor. Hold for a count of five, then repeat for at least five minutes. Do this three times per day for best results. A short walk or a few minutes on a stationary bike before bed also helps.
Other practical changes that can reduce nighttime cramps:
- Untuck your sheets. Tight bedding pushes your feet into a pointed position. Loosening the covers gives your feet room to stay neutral.
- Stay hydrated in the evening. Mild dehydration overnight can contribute to cramping, so drink water in the hours before bed (without overdoing it to the point of disrupting sleep).
- Wear shoes with support during the day. Foot fatigue from flat shoes or standing on hard surfaces can set the stage for cramps later that night.
When Cramps Signal Something Else
Most muscle cramps are harmless, even if they’re painful. But certain patterns deserve attention. Cramps that are far more severe than expected, happen alongside dark tea-colored or cola-colored urine, or come with unusual weakness or an inability to complete physical tasks you could do before may point to rhabdomyolysis, a condition where muscle tissue breaks down and releases proteins into the bloodstream that can damage the kidneys. The CDC lists these as the key warning signs.
Cramps that consistently affect the same muscle group, are accompanied by visible muscle wasting or persistent weakness, or don’t respond to any of the usual remedies may also warrant evaluation. Peripheral nerve problems, circulation issues, and certain medications (particularly diuretics and cholesterol-lowering drugs) can all cause cramps that won’t resolve with stretching and hydration alone.

