Why Do My Legs Cramp at Night? Causes and Relief

Nocturnal leg cramps are involuntary, painful muscle contractions that strike during sleep, most often in the calf. They affect 50 to 60 percent of adults at some point, and the likelihood climbs about 3 percent with each year of age. If you’re losing sleep to sudden, intense tightening in your lower legs, you’re dealing with one of the most common and least understood muscle complaints in medicine.

What Happens Inside the Muscle

A nocturnal leg cramp is not the same as a simple twitch. The muscle contracts hard and stays locked, sometimes for seconds, sometimes for several minutes. The pain can linger as soreness well into the next day. Calves are the most frequent target, though the foot and thigh can cramp too.

The leading explanation centers on nerve activity rather than the muscle itself. Motor neurons, the nerves that tell muscles to contract, become abnormally excitable during rest. When you’re sleeping, your legs are often in a slightly shortened position (toes pointed, knees bent), which may make the calf muscle more vulnerable to spontaneous firing from those overactive nerves. This neuromuscular theory has gained more support than the older idea that dehydration or electrolyte loss alone triggers cramps. Research comparing the two hypotheses found inconsistent evidence for the dehydration model, while the neuromuscular explanation better fits the pattern of cramps that hit during rest rather than during exercise.

That said, fluid and mineral balance still play a supporting role. If you’re low on magnesium or potassium, or you’ve been sweating heavily without replacing fluids, your nerves may be easier to trigger. The distinction matters because it means simply drinking more water won’t reliably prevent cramps for most people.

Who Gets Them Most Often

Age is the strongest predictor. In a large national survey, roughly a third of adults between 50 and 79 reported mild nocturnal cramps, with moderate to severe cramps affecting about 8 percent of that group. Among people 80 and older, the rate of moderate to severe cramps jumped to 11 percent. Women are slightly more prone than men across all age groups.

Pregnancy is another major trigger. Leg cramps commonly appear during the second and third trimesters, typically at night. The exact cause during pregnancy isn’t fully established, but lower circulating calcium levels may contribute. The cramps usually resolve after delivery.

Medical Conditions That Cause Cramps

Most nocturnal leg cramps are idiopathic, meaning there’s no identifiable underlying disease. But persistent or worsening cramps can signal something worth investigating. The conditions most strongly linked to night cramps include:

  • Peripheral artery disease (PAD): Narrowed arteries reduce blood flow to the legs, especially at rest when circulation naturally slows.
  • Diabetes: Both type 1 and type 2 diabetes can cause nerve damage in the legs, making motor neurons more likely to misfire.
  • Kidney disease: When the kidneys can’t properly filter waste and balance minerals, muscle irritability increases.
  • Liver cirrhosis: Scarring of the liver disrupts fluid and electrolyte regulation throughout the body.

If your cramps are new, frequent, or getting worse over time, they may be the first noticeable sign of one of these conditions, particularly if you also have numbness, swelling, or leg pain during walking.

Medications That Trigger Cramps

A surprisingly long list of common medications can cause or worsen nocturnal leg cramps. Diuretics (water pills) are among the most well-known culprits because they alter potassium and sodium levels. But the list extends well beyond them: cholesterol-lowering statins, blood pressure medications called angiotensin II receptor blockers, certain asthma inhalers that stimulate beta receptors, oral contraceptives, and even everyday stimulants like caffeine and nicotine.

Withdrawal from alcohol, sedatives, or anti-anxiety medications can also provoke cramps as the nervous system rebounds into a hyperactive state. If you started a new medication around the time your cramps began, that connection is worth raising with whoever prescribed it.

Lifestyle Factors That Play a Role

Long periods of sitting or standing in one position can set the stage for nighttime cramps. When muscles stay in one posture for hours, they stiffen, and the transition to sleep (where they shorten further) can tip them into spasm. People who sit at a desk all day and then go to bed without moving much in between tend to report more cramps than those who stay moderately active.

Overexertion works the other end of the spectrum. An unusually intense workout, a long hike, or yard work that pushes your legs harder than they’re used to can leave muscles fatigued and prone to cramping hours later when you’re asleep. The common thread is that muscles at either extreme, too little use or too much, are more irritable at night.

What Actually Helps Prevent Them

Stretching before bed is the most consistently recommended preventive measure. A simple standing calf stretch, where you lean into a wall with one leg extended behind you and the heel pressed flat, held for 30 seconds on each side, targets the muscle group most commonly affected. Doing this nightly gives the muscle fibers a chance to lengthen before you settle into the shortened sleeping position that invites cramps.

Beyond stretching, a few practical habits reduce frequency for many people:

  • Sleep position: Keeping sheets and blankets loose at the foot of the bed prevents your feet from being pushed into a toes-down position, which shortens the calf.
  • Light evening movement: A short walk or a few minutes on a stationary bike before bed promotes circulation without fatiguing the muscles.
  • Staying hydrated through the day: While dehydration alone probably doesn’t cause most cramps, chronic low fluid intake can lower the threshold for nerve excitability.
  • Supportive footwear: If you’re on your feet during the day, shoes that prevent the foot from overworking can reduce nighttime muscle fatigue.

What to Do When a Cramp Hits

When you wake up mid-cramp, your instinct to stretch the muscle is correct. Flex your foot upward, pulling your toes toward your shin, to oppose the contraction. If you can stand, pressing your heel into the floor and leaning forward stretches the calf under your own body weight and usually releases the spasm faster than stretching in bed. Massaging the knotted area and applying warmth afterward helps with the residual soreness that can last into the next morning.

Why Quinine Is No Longer Recommended

For decades, quinine (a compound originally used to treat malaria) was widely prescribed for leg cramps. It does reduce cramp frequency modestly, which is why some people still seek it out. But the FDA has determined that the risks far outweigh the benefits for what is, in most cases, a painful but not dangerous condition. Quinine can cause dangerous drops in platelet counts, life-threatening heart rhythm disturbances, severe allergic reactions, and chronic kidney damage. It is not FDA-approved for leg cramps, and the agency has specifically warned against using it for this purpose. The only approved use of prescription quinine in the U.S. is for malaria.

Some people try drinking tonic water, which contains small amounts of quinine. The concentration is far too low to have a meaningful effect on cramps, but it’s also too low to pose the serious risks associated with prescription doses.