Charley horses are preventable in most cases through a combination of hydration, stretching, and attention to your electrolyte intake. These sudden, involuntary muscle contractions originate in the nervous system, where dehydration, mineral imbalances, or fatigued nerves trigger a cascade of uncontrolled firing in the muscle. The good news: the most common causes are lifestyle factors you can change starting today.
Why Charley Horses Happen
A charley horse isn’t just a muscle tightening up on its own. It’s a neurological event. Nerves at the spinal cord level, the nerve-muscle junction, and even tiny sensory receptors inside the muscle itself can become hyperexcitable, firing rapidly and locking the muscle into a painful contraction. Dehydration is the most common trigger because losing fluids disrupts the electrical balance at the nerve-muscle junction, making it unstable and prone to misfiring.
Other common triggers include electrolyte depletion (especially potassium, magnesium, and calcium), muscle fatigue from prolonged exercise, sitting or standing in one position for hours, and sleeping with your feet pointed downward, which keeps your calf muscles in a shortened state all night.
Stay Ahead of Dehydration
Fluid intake is the single most impactful factor for most people who get recurring cramps. A practical formula from Mass General Brigham: multiply your body weight in pounds by 0.67 to get the number of ounces you need daily. Then add 12 ounces for every 30 minutes of exercise. A 150-pound person who works out for an hour, for example, needs roughly 125 ounces of water that day.
Don’t wait until you’re thirsty. By the time you feel thirst, your fluid levels have already dropped enough to affect nerve-muscle signaling. Keep water accessible throughout the day, and if you sweat heavily during exercise or in hot weather, include a drink with sodium and potassium to replace what you lose in sweat, not just plain water.
Get Enough Potassium and Magnesium
Electrolytes maintain the electrical charge across your muscle cell membranes. When potassium, magnesium, or calcium levels dip, those membranes become unstable and more likely to fire involuntarily. You don’t necessarily need supplements if you eat the right foods consistently.
For potassium, one avocado delivers about 975 milligrams, a cup of orange juice provides nearly 500 milligrams, and a 3-ounce serving of cooked salmon has roughly 326 milligrams. Tomato juice is another easy source, with about 15% of your daily potassium needs in a single cup.
For magnesium, beans are a standout. A cup of cooked black beans contains about 120 milligrams of magnesium, and a cup of cooked lentils has 71 milligrams. An ounce of roasted almonds adds around 74 milligrams. These numbers add up quickly across a full day of eating, and they come packaged with other nutrients your muscles need.
Does Magnesium Supplementation Work?
The evidence is modest but encouraging. A randomized, double-blind trial of 184 people tested 226 milligrams of magnesium oxide taken once daily against a placebo. After 60 days, the supplement group dropped from an average of 5.4 cramps per week to 1.9, while the placebo group only went from 6.4 to 3.7. Cramp duration also fell significantly, from about 4 minutes per episode to just over 1 minute in the treatment group.
That said, the American Academy of Family Physicians rates this as limited evidence from a single trial. Magnesium supplementation is generally safe for most people at moderate doses, but food sources are absorbed better and come without the digestive side effects (loose stools) that magnesium oxide sometimes causes. If you want to try a supplement, magnesium glycinate and magnesium citrate tend to be better absorbed than magnesium oxide.
Stretch Before Bed
If your charley horses strike at night, a short stretching routine before sleep can make a real difference. The Mayo Clinic specifically recommends pre-bedtime calf stretches for people with nocturnal leg cramps. A simple wall stretch works well: stand about two feet from a wall, press your palms against it, and step one foot back while keeping the heel flat on the floor. Hold for 20 to 30 seconds, then switch sides. Repeat two or three times per leg.
The goal is to lengthen the calf muscle so it’s less likely to spasm when it’s in a shortened position overnight. This is especially important if you spend most of your day sitting or wearing heeled shoes, both of which keep the calf in a contracted state.
Adjust Your Sleep Setup
Two small changes to your bed can reduce nighttime cramps. First, avoid sleeping with your toes pointed downward. Sleeping on your back with heavy blankets pressing your feet into a pointed position shortens the calf muscle for hours, which is a recipe for cramping. Try propping a pillow at the foot of the bed to keep your feet in a neutral position, or sleep on your back with your toes pointing toward the ceiling.
Second, use loose sheets and blankets. Tight bedding can force your feet into that pointed position even if you don’t start out that way.
Check Your Medications
Several common medications list muscle cramps as a side effect. Diuretics (water pills) are among the most frequent culprits because they flush electrolytes along with fluid. Statin cholesterol medications, oral contraceptives, certain blood pressure medications, and bronchodilators can also trigger cramps. Stimulants including caffeine, nicotine, and pseudoephedrine (found in many cold medicines) are on the list as well.
If you started getting cramps after beginning a new medication, that connection is worth discussing with your prescriber. Sometimes adjusting the dose or timing, or adding an electrolyte supplement, resolves the problem without needing to switch drugs.
Avoid Quinine
Quinine, sometimes found in tonic water, has a long folk reputation as a cramp remedy. The FDA has explicitly stated that quinine is not considered safe or effective for treating or preventing leg cramps. It carries a boxed warning for serious blood disorders including immune-related conditions that can cause kidney failure and death. Quinine is approved only for treating malaria. Any other use is off-label and carries real risk for a condition that has safer solutions.
Cramps During Pregnancy
Leg cramps are extremely common in the second and third trimesters, and the evidence for what prevents them during pregnancy is frustratingly unclear. A Cochrane review of eight trials involving 576 pregnant women found that magnesium supplements may reduce cramp frequency, but results were inconsistent across studies. Calcium, vitamin D, and calcium-vitamin D combinations showed no reliable benefit. Vitamin B showed some promise in a small study, but the evidence was too limited to draw conclusions.
None of the reviewed studies reported adverse effects on pregnancy, labor, or the baby, which is reassuring. The practical takeaway: staying well hydrated and eating potassium- and magnesium-rich foods is a low-risk approach. If cramps are disrupting your sleep regularly, your provider can help you weigh the options.
When Cramps Signal Something Else
Most charley horses are harmless, but certain patterns warrant attention. Peripheral artery disease, a narrowing of the blood vessels in the legs, causes cramping that reliably appears during walking or climbing stairs and stops when you rest. Other signs include coldness in one leg compared to the other, shiny skin on the legs, slow-growing toenails, sores on the feet or legs that heal slowly, and a weak or absent pulse in the foot. If your cramps follow this pattern, especially if you’re over 50, smoke, or have diabetes, that’s a different situation from a standard nighttime charley horse.
Cramps accompanied by visible swelling, redness, or warmth in one leg could indicate a blood clot and need prompt evaluation. Persistent cramping with muscle weakness, numbness, or cramps that spread to multiple muscle groups can sometimes point to nerve or muscle disorders that benefit from early diagnosis.

