What Can You Do for Leg Cramps at Night?

Stretching the cramping muscle is the fastest way to stop a nighttime leg cramp, and stretching before bed is the best-supported method for preventing them. Beyond that, a few other strategies can help reduce how often cramps strike and how intense they feel. Most nighttime leg cramps are harmless, but they can seriously disrupt sleep, and about one in three adults over 60 deals with them regularly.

How to Stop a Cramp in the Moment

When a calf cramp hits, passively stretch the muscle by flexing your foot upward, pulling your toes toward your shin. You can do this by grabbing your toes and pulling, or by standing and pressing your heel into the floor. Hold the stretch until the contraction releases, which typically takes 30 to 60 seconds. Avoid pointing your toes, since that shortens the calf muscle and can make the cramp worse or trigger a new one.

Walking around briefly after the cramp subsides helps reset the muscle. Some people find that massaging the area or applying a warm towel loosens the lingering tightness that can last for minutes or even hours after the cramp itself stops. Ice can also help if the soreness persists into the next day.

The Pickle Juice Trick

Drinking a small amount of pickle juice or vinegar at the onset of a cramp can shorten it noticeably. This works faster than any electrolyte replacement could, which suggests the effect isn’t about replenishing anything. Researchers at Brigham Young University found that the sharp taste triggers a reflex in the mouth and throat that signals the nervous system to quiet the overactive nerve firing causing the cramp. A few ounces is enough. Mustard, which also contains acetic acid, appears to work the same way for some people.

Stretching Before Bed to Prevent Cramps

A randomized trial of older adults found that stretching the calf and hamstring muscles every night before sleep reduced both the frequency and severity of leg cramps over six weeks. This is the single best-studied prevention strategy, and it’s simple to do.

For a basic calf stretch, stand facing a wall with one foot behind you, heel flat on the floor, and lean forward until you feel tension in the back calf. Hold for about 30 seconds, then switch legs. For the hamstrings, sit on the edge of your bed with one leg extended straight and gently lean forward from the hips. Doing both stretches nightly, right before you get into bed, is the routine that was tested and shown to work.

Why Magnesium Probably Won’t Help

Magnesium supplements are one of the most commonly recommended remedies for leg cramps, but clinical evidence doesn’t support them for most people. A well-designed crossover trial gave participants magnesium or a placebo and found no significant difference in cramp frequency: about 11 cramps during each treatment period regardless of which they received. Every participant improved over time no matter what they took, likely a combination of the condition’s natural tendency to come and go and a placebo effect.

The broader idea that nighttime leg cramps stem from electrolyte imbalances is also weaker than most people assume. The American Academy of Family Physicians notes that nocturnal leg cramps have no proven association with low potassium, sodium, magnesium, or other electrolyte abnormalities, and routine blood testing for these levels isn’t considered useful for diagnosis. The cramps are more likely caused by muscle fatigue and nerve dysfunction than by mineral deficits. That said, if you’re eating a diet low in potassium-rich foods like bananas, potatoes, and leafy greens, improving your overall nutrition certainly won’t hurt.

What About B Vitamins?

One small but rigorous study looked at vitamin B complex in elderly patients with high blood pressure who had severe nighttime leg cramps. After three months, 86% of the patients taking the B vitamin supplement experienced significant improvement in cramp frequency, intensity, and duration, while the placebo group showed no meaningful change. The supplement combined several B vitamins, including forms of B1, B6, B12, and B2. This is a single study with only 28 participants, so it’s not definitive, but the results were striking enough that B complex may be worth trying if cramps are frequent and disruptive.

Medications That Can Cause Cramps

Several common prescription drugs are linked to a higher risk of nighttime leg cramps. The three most frequently implicated classes are diuretics (water pills used for blood pressure), statins (cholesterol-lowering drugs), and inhaled long-acting bronchodilators used for asthma or COPD. Among these, potassium-sparing diuretics and thiazide-type diuretics showed the strongest associations in a large sequence analysis published in JAMA Internal Medicine.

If your cramps started or worsened after beginning a new medication, that connection is worth raising with whoever prescribed it. Adjusting the dose or switching to a different drug in the same class can sometimes resolve the problem entirely.

Lifestyle Habits That Help

Staying hydrated throughout the day matters, even though dehydration hasn’t been proven to directly cause nighttime cramps. Dehydrated muscles fatigue more easily, and fatigue is one of the leading theories for why these cramps happen in the first place. Drink water consistently rather than loading up right before bed, which just means more trips to the bathroom.

Avoid tucking your sheets in tightly at the foot of the bed. Heavy or tight bedding can push your feet into a pointed position, keeping your calf muscles in a shortened state for hours. Sleeping on your back with loose covers, or on your side with your feet hanging off the edge, helps keep the calves in a more neutral position. Some people use a pillow or rolled blanket at the foot of the bed to prop the covers up.

Light activity during the day, like walking, can help prevent cramps by keeping the muscles conditioned. But exercising intensely right before bed, or standing on hard surfaces for long periods, can increase cramp risk. The pattern for many people is that the muscles work hard during the day, then misfire at night when they’re finally at rest.

Cramps vs. Restless Legs Syndrome

Nighttime leg cramps and restless legs syndrome both strike at night and affect the lower limbs, but they feel very different. A cramp is a sudden, painful, involuntary contraction, usually in the calf, that you can see and feel as a hard knot. It comes on abruptly and forces you awake. Restless legs syndrome is more of an uncomfortable urge to move your legs, often described as crawling, tingling, or aching, that builds gradually when you’re sitting or lying still. Moving relieves restless legs; stretching relieves a cramp. If your nighttime leg discomfort is more restlessness than pain, you may be dealing with a different condition that has its own set of treatments.

When Cramps Signal Something Else

Most nighttime leg cramps are idiopathic, meaning there’s no identifiable underlying cause. But cramps that happen very frequently, affect both legs, or come with other symptoms like numbness, swelling, or skin changes can point to conditions worth investigating. Peripheral artery disease, peripheral neuropathy, poorly controlled diabetes, and lumbar spinal stenosis are all associated with more frequent cramping. The link with diabetes likely involves nerve damage and changes to small blood vessels over time. Conditions like heart failure, arthritis, and thyroid disease have also shown associations in large population studies. If your cramps are new, getting worse, or happening most nights, a medical evaluation can help rule out these possibilities.