Most leg cramps stop on their own within a few minutes, but you can cut that time short by stretching the cramping muscle and addressing the underlying triggers that cause cramps to keep coming back. There’s no single “cure” because leg cramps have multiple causes, from dehydration and mineral deficiencies to muscle fatigue and nerve signaling problems. The good news: a combination of immediate relief techniques and longer-term prevention strategies works for the vast majority of people.
How to Stop a Cramp Right Now
When a leg cramp strikes, your goal is to lengthen the muscle that’s locked in contraction. For a calf cramp (the most common type), straighten your leg and pull your foot upward so your toes point toward your shin. If you can reach your toes, gently pull them back. Walking around on your heels also forces the calf to stretch and can break the spasm quickly.
Beyond stretching, a few other techniques help in the moment:
- Massage the muscle with firm pressure to encourage it to relax.
- Apply heat to tight, knotted muscles, or wrap ice in a towel and press it to the area if the cramp has already released and you’re dealing with residual soreness.
- Elevate your leg once the cramp starts to ease to help reduce any lingering discomfort.
Some athletes swear by pickle juice as a fast cramp stopper. Recent research suggests this works not because of its salt content but because the strong, sour taste triggers a nervous system reflex that interrupts the cramp signal before your body even absorbs the liquid.
Why Leg Cramps Happen
There are two main theories for what causes leg cramps, and both likely play a role depending on the situation.
The first is electrolyte and fluid imbalance. Your muscles rely on electrically charged minerals (sodium, potassium, calcium, and magnesium) to contract and relax properly. When you lose these minerals through sweat, don’t drink enough water, or have an imbalance from diet or medication, your muscles become more prone to involuntary contractions. Studies of industrial workers in hot environments found that providing salt-containing drinks dramatically reduced cramping rates, and lab research has shown that muscles become more susceptible to cramping when people drink plain water after sweating heavily compared to drinking something with electrolytes.
The second theory focuses on neuromuscular fatigue. When a muscle is overworked or held in a shortened position for a long time, the normal feedback loop between your muscles and spinal cord gets disrupted. Sensors in your tendons that normally tell the muscle to stop contracting become less active, while sensors that encourage contraction become overactive. This creates a runaway loop of involuntary firing. It’s why cramps tend to hit muscles that are already tired or have been in the same position for hours, like your calves during sleep.
Foods That Help Prevent Cramps
Rather than chasing a single miracle food, aim to consistently eat foods rich in the four key electrolytes: potassium, magnesium, calcium, and sodium.
Potassium-rich options include bananas, avocados (about 975 milligrams per avocado), sweet potatoes, salmon, and orange juice, which delivers nearly 500 milligrams per cup. A cup of tomato juice gives you roughly 15% of your daily potassium needs.
For magnesium, beans and lentils are standouts. A cup of cooked black beans contains about 120 milligrams, and a cup of cooked lentils has around 71 milligrams. Dark leafy greens like spinach, kale, and broccoli are rich in both magnesium and calcium. An ounce of roasted almonds packs about 74 milligrams of magnesium, and sunflower seeds offer about 37 milligrams per ounce.
Milk is a natural source of calcium, potassium, and sodium all at once, and its protein helps repair muscle tissue after exercise. Melons are another good all-around choice because they deliver potassium, magnesium, calcium, and a lot of water. Watermelon is about 90% water, making it especially useful for hydration. Speaking of which, women generally need about 11.5 cups of water daily and men about 15.5 cups, though exercise and heat increase those needs.
Does Magnesium Supplementation Work?
Magnesium is the most commonly recommended supplement for leg cramps, but the evidence is weaker than most people expect. A review by the American Academy of Family Physicians concluded that magnesium supplements should not be expected to help for courses shorter than 60 days. There is limited evidence that magnesium oxide taken daily may improve cramps after the 60-day mark, but short-term use doesn’t appear to outperform a placebo.
That said, if your diet is genuinely low in magnesium, correcting the deficiency through food or supplements makes physiological sense. The issue is that many people take magnesium expecting fast results and give up before any benefit could realistically appear. If you try supplementation, plan on at least two months before judging whether it’s helping.
Preventing Nighttime Cramps
Nocturnal leg cramps are especially common in adults over 50, and they tend to hit the calves or the small muscles of the feet. A few habits can reduce how often they happen.
Stretching your calves before bed is the simplest intervention. Stand facing a wall with one foot forward and one back, keeping your back heel on the floor, and lean into the wall until you feel a stretch in the back calf. Hold for 20 to 30 seconds and switch sides. Doing this nightly gives your muscles a longer resting length going into sleep, which makes that neuromuscular feedback loop less likely to misfire.
How your feet are positioned in bed matters too. Heavy blankets can push your feet into a pointed-toe position, which shortens the calf muscles for hours. Try loosening the sheets at the foot of the bed or using a pillow to prop the covers off your feet. Staying hydrated throughout the day (not just at bedtime) also helps, since dehydration develops cumulatively.
Exercise-Related Cramps
Cramps during or after exercise tend to strike muscles that are doing the most work, particularly when you push harder or longer than your body is conditioned for. The combination of fatigue and fluid loss creates a perfect storm.
To reduce exercise-related cramping, build up training intensity gradually so your muscles adapt before they’re pushed to the point of fatigue. Drink fluids with electrolytes during prolonged exercise rather than plain water alone. Some athletes use compression socks for recovery, and while the evidence is mostly anecdotal, the idea is that graduated pressure supports circulation and may reduce post-exercise muscle soreness and cramping.
If cramps consistently hit the same muscle group during exercise, that muscle may simply be weaker or tighter than the rest. Targeted strengthening and flexibility work for that area often helps more than any supplement.
When Cramps Signal Something Else
Occasional leg cramps are almost always harmless. But certain patterns deserve attention. Peripheral artery disease, a condition where narrowed blood vessels reduce blood flow to the legs, causes cramping pain in the calves, thighs, or hips during walking or climbing stairs that reliably goes away with rest. Other signs include coldness in one lower leg compared to the other, numbness, weakness, or a weak pulse in the feet. PAD-related pain can range from mild to severe and may even wake you from sleep.
Cramps that are persistent, worsening over time, not responding to hydration and stretching, or accompanied by muscle weakness, swelling, or skin changes are worth bringing up with a doctor. Certain medications, including diuretics and cholesterol-lowering drugs, can also cause or worsen leg cramps by affecting fluid balance or muscle tissue.
Avoid Quinine for Cramps
Quinine, sometimes found in tonic water and available by prescription for malaria, was once commonly used off-label for leg cramps. The FDA has issued strong warnings against this. Quinine is associated with life-threatening side effects including a dangerous drop in blood platelets, heart rhythm problems, severe allergic reactions, kidney failure requiring dialysis, and deaths. The FDA has added a boxed warning (the most serious type) to quinine labeling and conducted multiple campaigns to discourage its use for cramps. It is not considered safe or effective for this purpose.
Cramps During Pregnancy
Leg cramps are common during pregnancy, typically appearing in the second and third trimesters. A Cochrane review of eight trials involving 576 pregnant women found that magnesium, calcium, and vitamin B supplements each showed some promise for reducing cramp frequency, but the overall evidence quality was low. In one trial, women taking magnesium were significantly more likely to report complete resolution of leg cramps and reduced pain intensity. Calcium showed similar trends in a small study. Vitamin B supplements also reduced the combined frequency and intensity of cramps in one trial.
None of these interventions had strong enough evidence to be called a definitive treatment, and no trials evaluated non-supplement approaches like stretching, massage, or heat therapy. Given the safety profile, gentle calf stretches before bed and adequate hydration remain reasonable first steps during pregnancy, with mineral supplementation as an option to discuss with a prenatal care provider.