Most leg cramps stop within seconds to minutes if you stretch the affected muscle and keep it lengthened. Preventing them from coming back takes a bit more work: staying hydrated, getting enough key minerals, and adjusting habits that put your muscles under unnecessary strain. Here’s what actually helps, both in the moment and over time.
What to Do During a Cramp
When a cramp hits your calf, straighten your leg and flex your foot, pulling your toes toward your shin. This lengthens the muscle that’s seizing up and forces it to relax. Gently rubbing the area while you hold the stretch can speed things along. For a thigh cramp (front of the leg), bend your knee and pull your foot up toward your buttock. Hold onto a chair or wall for balance. In either case, keep the stretch going until the spasm fully releases, typically 15 to 30 seconds.
Once the cramp passes, walk around slowly to restore normal blood flow. Applying a warm towel or heating pad to the muscle can ease residual soreness. Ice works too if the area feels inflamed, though warmth is usually more comfortable.
Why Cramps Happen in the First Place
There’s no single cause, which is part of what makes cramps frustrating. Two main theories explain most cases. The older explanation points to dehydration and electrolyte loss through sweat. When you lose fluids and minerals faster than you replace them, your muscles become more excitable and prone to involuntary contractions.
The newer, more widely accepted theory focuses on how your nervous system controls muscle activity. During exercise or prolonged use, the signals telling a muscle to contract can overpower the signals telling it to relax. This imbalance ramps up nerve firing and triggers a cramp, especially when the muscle is already in a shortened position (like a pointed foot in bed). This “altered neuromuscular control” theory helps explain why cramps often strike at night or at the end of a long workout, when muscles are fatigued and nerve signaling is less precise.
In practice, both mechanisms probably contribute. Dehydration makes nerve signaling less reliable, and fatigue tips the balance toward uncontrolled contraction. That’s why prevention targets both hydration and muscle conditioning.
Minerals Your Muscles Need
Four electrolytes play direct roles in muscle function: sodium, potassium, magnesium, and calcium. Sodium controls fluid levels and helps nerves fire. Potassium supports the electrical signals that make muscles contract and relax. Magnesium aids nerve and muscle function at a cellular level. Calcium helps blood vessels and nerves communicate. When any of these drop too low, muscle cramps, spasms, and weakness can follow.
Magnesium gets the most attention as a supplement for cramps. A randomized, placebo-controlled trial of 184 people tested a daily magnesium supplement against a placebo for 60 days. The supplement group went from an average of 5.4 cramps per week down to 1.9, while the placebo group only dropped from 6.4 to 3.7. Cramp duration fell dramatically too: from about four minutes per episode to just over one minute. The catch is that shorter courses (under 60 days) don’t show reliable benefits, according to a review by the American Academy of Family Physicians. If you try magnesium, give it at least two months before judging whether it’s working.
For potassium and sodium, food is usually the better source. Bananas, potatoes, beans, and leafy greens are rich in potassium. Sodium is rarely a problem in a normal diet, but if you exercise heavily and sweat a lot, you may need to be more intentional about replacing it through salted foods or sports drinks.
Hydration Before, During, and After Exercise
Not getting enough sodium through food or fluids can directly cause muscle cramps, and dehydration amplifies the problem. The National Athletic Trainers’ Association recommends drinking 16 to 24 ounces of water within two hours before exercise, then another 7 to 10 ounces about 10 to 20 minutes before you start. During exercise, aim for 6 to 12 ounces every 10 to 20 minutes.
After exercise, weigh yourself. For every pound lost during your session, drink 16 to 24 ounces of water. This matters most in hot or humid conditions, at high altitude, and for people with naturally high sweat rates. If your cramps tend to strike during or right after workouts, inadequate fluid replacement is one of the first things to address.
Preventing Nighttime Cramps
Nocturnal leg cramps are extremely common, especially after age 50. They often target the calf and can jolt you awake with intense pain. A few adjustments to your evening routine can reduce how often they happen.
Stretch your calves and hamstrings before bed. Stand facing a wall, place one foot behind you with the heel flat on the floor, and lean forward until you feel a pull in the back calf. Hold for 20 to 30 seconds on each side. This keeps the muscles lengthened going into sleep, which counteracts the shortened position your feet often fall into under blankets.
Sleep position matters too. Heavy blankets or tucked-in sheets can push your feet into a pointed-toe position, shortening the calf muscles for hours. Loosening your sheets at the foot of the bed or sleeping with your feet hanging slightly off the edge can help. Some people find that wearing supportive shoes during the day (rather than flat sandals or going barefoot) reduces nighttime cramping by lowering overall calf fatigue. Research on prolonged standing shows that shoes with some arch structure reduce lower leg discomfort and swelling compared to flat-soled shoes or bare feet.
The Pickle Juice Trick
Pickle juice has a real, measurable effect on cramps, and it’s not about replacing electrolytes. The acetic acid in the brine triggers nerves in the back of the throat, which send a signal that essentially switches off the cramp reflex. It works within seconds, far too fast for any mineral absorption to explain.
In a clinical trial, 69% of people who sipped a tablespoon of pickle juice when a cramp started reported that it stopped the cramp, compared to 40% in a group that sipped tap water. It didn’t prevent cramps from occurring in the first place, but as a rescue remedy, it outperformed water by a significant margin. A tablespoon is all you need. Mustard, which also contains acetic acid, may work through the same mechanism, though it’s less studied.
Medications That Can Cause Cramps
Certain medications make cramps more frequent by affecting hydration, electrolyte balance, or muscle metabolism. Diuretics (water pills) are among the most common culprits because they flush sodium and potassium out through urine. Statins, used to lower cholesterol, can cause muscle pain and cramping in some people. Blood pressure medications, asthma drugs, and hormonal treatments have also been linked to increased cramping.
If your cramps started or worsened after beginning a new medication, that connection is worth raising with your prescriber. Adjusting the dose or switching to a different option often resolves the problem.
When a Cramp Might Be Something Else
Ordinary cramps are painful but harmless. They come on suddenly, peak quickly, and fade within minutes. A few signs suggest something more serious, particularly a deep vein blood clot. Clot-related leg pain is almost always in one leg, not both. Unlike a cramp, the pain is constant and doesn’t ease up. You may notice significant swelling (not just mild ankle puffiness) along with redness or warmth in the skin.
If you have persistent, one-sided leg pain with swelling that doesn’t behave like a cramp, a simple ultrasound can rule out a clot in about 15 minutes. Chest pain, sudden shortness of breath, or dizziness alongside leg symptoms are emergency signs that a clot may have moved to the lungs.

