Leg cramps happen when a muscle involuntarily contracts and won’t relax. The most common culprits are muscle fatigue, dehydration, electrolyte imbalances, and prolonged sitting or standing, though several medications and medical conditions can also trigger them. Nearly every adult over 50 will experience leg cramps at some point, and a third of people over 60 get them at night at least once every two months.
How a Cramp Forms Inside the Muscle
A normal muscle contraction starts with a nerve signal that tells muscle fibers to tighten, followed by a second signal that tells them to release. Cramps occur when something disrupts that release phase. In most cases, the problem is neurogenic, meaning it starts with the nerves rather than the muscle itself. Motor neurons become hyperexcitable, firing repeatedly when they shouldn’t be. This can happen at several points along the chain: at the junction where nerve meets muscle, within the spinal cord, or along the nerve fibers themselves.
Your muscles also have built-in sensors that regulate contraction. Muscle spindles detect stretch and promote contraction, while Golgi tendon organs act as a brake, signaling the muscle to relax when tension gets too high. During fatigue, this balance tips. Spindle activity increases while the braking signal weakens, leaving the motor neuron firing unopposed. That’s why cramps so often strike at the end of a long run or after hours on your feet.
There’s a less common type of cramp that originates in the muscle itself rather than the nerves. When muscle cells can’t produce enough energy, the protein filaments that slide together during contraction physically can’t disengage. Muscle relaxation is an active process that requires cellular energy. Without it, the muscle locks up. This type is typically seen in people with metabolic muscle disorders rather than in everyday cramping.
Electrolytes and Hydration
Four electrolytes play direct roles in muscle function: sodium, potassium, magnesium, and calcium. Sodium controls fluid balance and helps transmit nerve signals. Potassium supports the electrical activity in muscle and nerve cells. Magnesium aids the nerve-to-muscle communication that governs contraction and relaxation. Calcium helps blood vessels regulate blood flow to working muscles. When any of these minerals drops too low, the electrical signals controlling your muscles become erratic, and cramps, spasms, or weakness can follow.
You don’t need to be severely deficient for this to matter. Heavy sweating during exercise or hot weather flushes sodium and potassium out faster than most people replace them. Drinking large volumes of plain water without replacing electrolytes can actually dilute what’s left, making the imbalance worse. Vomiting, diarrhea, and certain medications (particularly diuretics used for blood pressure) accelerate electrolyte loss as well.
Despite its reputation as a cramp remedy, magnesium supplementation doesn’t hold up well under scrutiny. A Cochrane review combining five well-designed trials found that magnesium supplements did not meaningfully reduce cramp frequency, intensity, or duration in older adults compared to a placebo. The percentage of people who saw a 25% or greater reduction in cramps was virtually the same whether they took magnesium or a sugar pill. If you’re eating a reasonably varied diet, extra magnesium tablets are unlikely to solve a cramping problem.
Exercise and Muscle Fatigue
Exercise-associated cramps are the most familiar type for active people. They tend to strike during or just after intense or prolonged activity, especially in hot conditions. The dominant explanation is that fatigue disrupts the normal feedback loop between your muscles and nervous system. As a muscle tires, its internal sensors start sending conflicting signals: more excitation, less inhibition. The result is a sustained involuntary contraction.
Cramps are also more likely when a muscle contracts while already in a shortened position. Pointing your toes in bed, for instance, shortens the calf muscle, which is one reason nighttime calf cramps are so common. Preparing muscles for exercise through progressive training, warming up before intense effort, and pacing yourself to respect fatigue all reduce the risk of exercise-related cramps.
Nighttime Leg Cramps
Nocturnal leg cramps, the kind that jolt you awake with a rock-hard calf, are extremely common but poorly understood. Several daytime habits increase the risk: sitting for long stretches at a desk, standing or working on concrete floors, overusing your muscles during the day, and maintaining poor posture. The calf and foot muscles are the usual targets because they spend much of the day in a slightly shortened position, particularly if you wear shoes with a heel.
Age is the strongest risk factor. The nerves that control your leg muscles gradually lose some motor neurons over the decades, and the remaining neurons become more excitable to compensate. This is why nighttime cramps become almost universal in older adults even when nothing else is medically wrong.
Pregnancy and Leg Cramps
Leg cramps are especially common during the second and third trimesters. Your blood volume nearly doubles during pregnancy, which can slow circulation in the legs and lead to swelling and cramping. At the same time, the growing uterus puts increasing pressure on the blood vessels that supply your lower body. When those vessels are compressed, blood return from the legs slows, and cramps become more frequent. The added weight also fatigues leg muscles faster than usual, compounding the problem.
Medications That Trigger Cramps
Several common medications list muscle cramps as a side effect. Diuretics (water pills) are among the most frequent offenders because they increase urination and flush electrolytes along with fluid. Statins, prescribed for high cholesterol, have a long-standing reputation for causing muscle symptoms. However, a large analysis of 19 clinical trials found that 27.1% of people taking statins reported muscle pain, weakness, or cramps, compared to 26.6% of people taking a placebo. That means statins cause roughly 11 additional episodes of muscle symptoms per 1,000 people treated. Most muscle complaints attributed to statins are likely unrelated to the drug itself.
When Leg Pain Signals Something Else
Most leg cramps are harmless, but two conditions can mimic or overlap with cramp-like pain and deserve attention.
Peripheral artery disease causes a cramping pain in the legs during walking or exercise that reliably goes away with rest. The pain comes from narrowed arteries that can’t deliver enough blood to meet your muscles’ demand during activity. Unlike a true muscle cramp, which is a sudden involuntary spasm, claudication (the medical term for this symptom) tends to build gradually at a predictable level of exertion. As the condition progresses, the pain can begin occurring at rest.
Deep vein thrombosis, a blood clot in a deep leg vein, can also feel like a cramp. The key differences are the accompanying signs: persistent swelling in one leg, skin that feels warm to the touch, and a color change (redness or a purplish tint). A typical muscle cramp resolves within minutes and doesn’t cause lasting swelling or discoloration. If you have cramping pain in one leg along with swelling, warmth, or skin color changes, that combination warrants prompt medical evaluation.
Stopping a Cramp in the Moment
When a cramp hits, the goal is to manually lengthen the muscle and override the contraction signal. For a calf cramp, flex your foot by pulling your toes toward your shin. You can do this by standing and pressing your heel into the floor, or by grabbing your toes and pulling them back while seated or lying down. Hold the stretch steadily rather than bouncing. Walking around on the affected leg also helps because it forces the calf to lengthen with each step.
For a thigh cramp in the front of the leg (quadriceps), bend your knee and pull your foot toward your buttock. For a hamstring cramp in the back of the thigh, straighten the leg and lean forward at the hips. Massaging the muscle and applying warmth after the cramp releases can ease the residual soreness that sometimes lingers for hours.
Reducing Cramp Frequency Over Time
Consistent calf stretching before bed is one of the most commonly recommended preventive strategies for nocturnal cramps. Standing on the edge of a step and letting your heels drop below the platform stretches both the calf and the deeper muscles of the lower leg. Staying well-hydrated throughout the day, particularly if you exercise or work in heat, helps maintain the electrolyte balance your muscles need. Choosing beverages with some sodium and potassium after heavy sweating is more effective than plain water alone.
If you sit for long periods, periodic movement breaks keep blood flowing through your legs and prevent the muscle shortening that sets the stage for cramps. Wearing supportive, flat-soled shoes reduces the amount of time your calf muscles spend in a contracted position. And if your cramps started or worsened after beginning a new medication, that connection is worth discussing with whoever prescribed it.

