Why do diabetics get leg cramps at night?
If you have type 2 diabetes and you are waking up at night with a calf seized in pain, you are not alone. You are not imagining it either. In one study of diabetic patients, the age-adjusted prevalence of muscle cramps was 65.2% in type 2 diabetes versus 45.5% in healthy controls.1 The cramps were also more severe and more disabling. The question is why.
This article walks through what the research says about nighttime leg cramps in people with type 2 diabetes. We will cover six factors that come up repeatedly in the literature. Most adults with diabetes have more than one of them at the same time. We are not telling you what to take or what to stop. The goal is to give you a clearer picture of what may be going on. The next conversation with your doctor should be a better one for it.
The short version
Nighttime leg cramps in adults with type 2 diabetes are usually multi-causal. Researchers describe contributions from nerve changes, circulation problems, blood sugar variability, hydration status, mineral status, and the side effects of common medications. The exact mechanism in any one person is often hard to pin down. A 2012 review in American Family Physician noted plainly that the precise mechanism of nocturnal leg cramps is not fully understood, even outside diabetes.
Below, we look at each of the six factors in turn.
1. Nerve changes (peripheral neuropathy)
This is the largest single factor in the diabetic leg cramp literature. In the study referenced above, neuropathy was the strongest independent predictor of muscle cramps in patients with diabetes. It outranked age, sex, and duration of disease.1 A separate cross-sectional study published in Annals of Saudi Medicine looked specifically at nocturnal leg cramps in type 2 diabetes and found a similar pattern.2
The proposed mechanism is that damaged or irritated motor nerves fire spontaneously. They send a contraction signal to the muscle when none was intended. The muscle obeys, locks up, and the person wakes up. This is a candidate mechanism rather than a settled one. Researchers are still working out the details. But it is the explanation that fits the evidence best so far.
2. Circulation changes
Years of high blood sugar can narrow the small and medium arteries that feed the legs. The clinical name for this is peripheral artery disease, or PAD, and it is more common in people with diabetes than in the general population.3
One feature of more advanced PAD is what doctors call "rest pain." This is discomfort in the legs or feet that gets worse when lying flat. It improves when the leg is dangled over the edge of the bed.3 This is not the same as a classic muscle cramp. The two can feel similar in the moment, though, and they can occur in the same person. If your nighttime leg pain improves when you stand up or hang your foot off the bed, that is worth mentioning to your doctor.
3. Overnight blood sugar variability
Blood sugar is not flat overnight, even in non-diabetic people. In adults with type 2 diabetes, the body's natural overnight rise of cortisol and growth hormone can produce something called the dawn phenomenon. This is a rise in blood glucose between roughly 3 a.m. and 8 a.m. Studies suggest it affects more than half of people with type 2 diabetes.4
Why this matters for cramps: large swings in blood glucose are accompanied by shifts in fluid and electrolytes across cell membranes. Both nerves and muscles are sensitive to those shifts. The dawn phenomenon by itself does not cause cramps. It is one of several reasons, though, that the early morning hours can be when the legs are most likely to act up.
4. Hydration
When blood sugar is high, the kidneys pull more water out of the body to flush the excess glucose. This is part of why frequent urination and thirst are classic diabetes symptoms. The same process can leave a person mildly dehydrated overnight, especially if blood sugar was elevated before bed.
Dehydration is one of the most reliable triggers of muscle cramps in any population. It is also one of the easiest to address. That is why most clinical reviews of nocturnal cramps mention it first.
5. Mineral status
Several minerals are involved in how muscles contract and relax. Potassium, calcium, sodium, and magnesium all participate in the signaling that tells a muscle to fire and then to release. When any of them runs low, the relaxation step can be slower or incomplete.
Magnesium is worth a particular note here. The research on magnesium status in type 2 diabetes is fairly consistent. A 2024 meta-analysis pooling 19 studies found a prevalence of low serum magnesium around 32% in people with type 2 diabetes.5 Hypomagnesemia is the medical term for low blood magnesium. A separate review estimates it is roughly ten times more common in type 2 diabetes than in the healthy population.6
Mechanistically, magnesium is a cofactor in the enzymatic step that pumps calcium back out of the muscle cell after a contraction.7 That is the step that lets the muscle release. When magnesium is low, the release step is one of the things that can be affected. Other minerals participate in the same process, so this is not a single-mineral story.
Less than 1% of the body's magnesium is in the bloodstream. The rest sits inside cells and bone. A standard blood test for magnesium reflects only that small extracellular fraction. So a normal result does not necessarily mean total body magnesium is adequate.8 This is why a person can have symptoms consistent with low magnesium and still be told their labs are fine.
6. Common medications
Many adults with type 2 diabetes are also taking one or more common prescriptions. Metformin for blood sugar. A statin for cholesterol. A thiazide diuretic for blood pressure. Each of these has been linked, in different ways, to leg cramps or muscle symptoms.
Metformin
Long-term metformin use has been associated with lower serum magnesium in type 2 diabetes patients. A proposed mechanism involves a transporter called TRPM6 in the gut and kidney. TRPM6 regulates how much magnesium the body absorbs and reabsorbs. In cell studies, long-term metformin exposure lowered TRPM6 expression and reduced magnesium uptake.9 This mechanism is described in the literature as plausible rather than fully settled. Gut losses from metformin-related diarrhea are also part of the picture.
Statins
Cramps and aches are the most commonly reported side effect of statin medications. Estimates of how often they occur vary widely. Reports range from about 1.5% in some clinical trials to 15–20% in real-world use.10 The proposed mechanisms are still being worked out. They involve mitochondrial energy production and calcium handling inside muscle cells.
Thiazide diuretics
Thiazide diuretics, often prescribed for high blood pressure, increase the excretion of potassium and magnesium in the urine. A large cross-sectional study from the Rotterdam Study cohort looked at this. Long-term thiazide use was associated with roughly a three-fold increase in the odds of low blood magnesium.11 Cramps are listed among the recognized adverse effects in clinical references.
A "controlled" A1C does not always mean a comfortable body. The two questions answer different things.
What to do with this information
This article is education, not advice. With that said, two things are worth saying.
First, talk to your doctor. Bring up the cramps directly. Ask whether your current medications could be contributing. Ask what your most recent magnesium and potassium levels were. Ask whether they were measured at all. Do not stop or change the dose of any prescription on your own. The conditions those medications are treating are real. Abrupt changes can cause more problems than the cramps did.
Second, know that nighttime leg cramps in a person with type 2 diabetes are rarely about one thing. They are usually about three or four things stacked together. That is also why no single intervention works for everyone. Not a glass of water before bed. Not a stretch routine. Not a mineral supplement.
The honest summary
Nighttime leg cramps are common in adults with type 2 diabetes. They are more common, more severe, and more disabling than in matched non-diabetic adults. The factors that come up repeatedly in the research are nerve changes, circulation, overnight blood sugar variability, hydration, mineral status, and medication side effects. Each one has a body of evidence behind it. None of them is the whole answer.
What this means in practice is simple. A useful conversation with a doctor treats the cramps as a signal worth investigating. Not as a side complaint to be brushed off. The research is the research. What to do with it is a clinical question.
References
- Katzberg H, Kokokyi S, Halpern E, Lovblom E, Barnett C, Hume D, Bril V, Perkins B. Prevalence of Muscle Cramps in Patients With Diabetes. Diabetes Care. 2014;37(1):e17–e18. https://diabetesjournals.org/care/article/37/1/e17/32017/
- Bensouda A, Benyaich H, El Alaoui O, et al. Prevalence and characteristics of nocturnal leg cramps in patients with type 2 diabetes. Annals of Saudi Medicine. 2021;41(1):14–20. PMID: 33496660. https://pubmed.ncbi.nlm.nih.gov/33496660/
- Yamamoto K, Natsuaki Y, Hayashi M, et al. Diabetes Mellitus and Lower Extremity Peripheral Artery Disease. JMA Journal. 2021;4(3):225–231. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8355746/
- Monnier L, Colette C, Dejager S, Owens DR. The Dawn Phenomenon Revisited: Implications for Diabetes Therapy. Endocrine Practice. 2015;21(5):568–579. https://www.endocrinepractice.org/article/S1530-891X(20)39957-2/fulltext
- Yadav UCS, Mehta S, Mehta P, et al. Global prevalence of hypomagnesemia in type 2 diabetes mellitus — a comprehensive systematic review and meta-analysis of observational studies. Endocrine. 2024;83(3):530–541. PMID: 38159172. https://pubmed.ncbi.nlm.nih.gov/38159172/
- Oost LJ, Tack CJ, de Baaij JHF. Hypomagnesemia and Cardiovascular Risk in Type 2 Diabetes. Endocrine Reviews. 2023;44(3):357–378. https://academic.oup.com/edrv/article/44/3/357/6811786
- Negri S, Sanchez-Alavez M, Aliprandi M, et al. The Yin and Yang of Heartbeats: Magnesium–Calcium Antagonism Is Essential for Cardiac Excitation–Contraction Coupling. Cells. 2025;14(16):1280. https://www.mdpi.com/2073-4409/14/16/1280
- Razzaque MS. Magnesium: Are We Consuming Enough? Nutrients. 2018;10(12):1863. https://pmc.ncbi.nlm.nih.gov/articles/PMC6316205/
- Kurstjens S, Bouras H, Overmars-Bos C, et al. Metformin regulates TRPM6, a potential explanation for magnesium imbalance in type 2 diabetes patients. Canadian Journal of Physiology and Pharmacology. 2020;98(7):443–451. PMID: 32017603. https://pubmed.ncbi.nlm.nih.gov/32017603/
- Mallinson JE, Marimuthu K, Murton A, et al. Statin myalgia is not associated with reduced muscle strength, mass or protein turnover in older male volunteers. The Journal of Physiology. 2015;593(5):1239–1257. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4358682/
- Kieboom BCT, Zietse R, Ikram MA, Hoorn EJ, Stricker BH. Thiazide but not loop diuretics is associated with hypomagnesaemia in the general population. European Journal of Clinical Pharmacology. 2018;74(11):1457–1464. PMID: 30095199. https://pubmed.ncbi.nlm.nih.gov/30095199/