Nocturnal skeletal muscle cramping when restarting a ketogenic diet: my rationale for supplementing with potassium, magnesium, and salt

Insulin drugs are known to cause debilitating muscle pain or cramping in some people, notably in Type 2 diabetics and soon after injection. Further, insulin drugs are known to cause a decrease in serum potassium, which can potentially lead to hypokalemia.

Ballout and Arabi¹ present a case of a patient with Type 2 diabetes and painful and prolonged muscle cramps. The patient was examined and found to have extensive diabetic axonal polyneuropathy. However, it was also observed that serum potassium dropped by about 16% after insulin injection. Further, supplemental potassium led to rapid resolution of cramps when they occurred and an overall reduction in the frequency of recurrence.



Talk with your doctor if you medicate with insulin or other drugs affecting serum potassium and you experience muscle pain or cramping.

If you are pre-diabetic, or think you may have bouts of hyperinsulinemia, and have muscle pain or cramping, consider changing what you eat and when you eat to lower serum insulin. Talk with your doctor about your thoughts on supplementing with potassium and trying a ketogenic diet as a drug-free way to resolve your muscle pain and cramping.


What about nocturnal cramps? These occur while sleeping and several hours after the last meal when serum insulin should be depleted.

There are abundant anecdotal testimonies purporting the resolution of nocturnal cramping with supplementation of magnesium, potassium, salt, and/or water.

The low hanging fruit is magnesium deficiency. Over 50% of all Americans are deficient in magnesium. It is well known that magnesium has been depleted from food over time. Also, hypomagnesemia can present with alcohol abuse and gastrointestinal and renal losses. Magnesium deficiency has been associated with critical health issues, including cardiovascular disease, type 2 diabetes, and osteoporosis.² 

Magnesium therapy has been found to alleviate eclampsia and preeclampsia, arrhythmia, severe asthma, and migraine.³ There is no known experimental or clinical evidence that shows magnesium therapy alone resolves skeletal muscle cramping, except maybe during pregnancy, although the research is sparse.⁴

Hypomagnesemia is causative of hypokalemia (low serum potassium), and hypomagnesemia must be resolved before hypokalemia can be resolved.⁵ ⁹

Normally, for homeostasis, potassium in the blood is pumped back into cells when needed or excreted by the kidneys when not needed. Kidney disease, hyperglycemia, hypomagnesemia, and drug use are known causes of hyperkalemia. In emergencies, insulin is administered to lower serum potassium.⁶ This treatment drives the potassium from the bloodstream back to the cells. 

A primary function of the kidneys to maintain the cation balance of serum sodium and potassium. 

Hypernatremia (i.e., excess serum sodium) and body water loss are also associated with hyperglycemia (excess serum glucose). With healthy kidneys, hypernatremia may present with hyperglycemia, or hyperkalemia (excess serum potassium) may present with hyperglycemia, but not both at the same time. Conversely, both hyponatremia and hypokalemia may present at the same time (possibly due to excess body water).⁷

In a healthy metabolism, insulin drives potassium into cells from the blood in exchange with intracellular sodium to maintain cation balance. It is inferred that a low insulin condition allows for the reverse intracellular exchange of potassium and sodium: potassium out of the cells and into the blood, and sodium out of the blood and into the cells.

What if there is not a sufficient period of time of low insulin, such as a condition of hyperinsulinemia and hyperglycemia (like type 2 diabetes)? Body water volume decreases due to hyperglycemia, and potassium and/or sodium may be excreted to maintain cation homeostasis. Additionally, serum potassium would become depleted faster as insulin drives potassium into the cells up to some limit. With the ion exchange, serum sodium increases until the cellular potassium limit is reached. Water may be ingested in response to thirst caused by the increased sodium and hypovolemia (decreased body water), but while added water improves serum sodium concentration it worsens serum potassium concentration. 

Eventually, such a condition may also alter the cation balance of magnesium, calcium, and phosphate⁸ as well as create compensating hormonal imbalances.

Unmanaged type 1 diabetes is a condition of hypoinsulinemia and hyperglycemia. In this case, hyperkalemia and lowered cellular potassium are possible. As mentioned by Ballout and Arabi¹, skeletal muscle cramping is not typically reported by type 1 diabetics.

It appears likely that either or both low serum potassium and/or high intracellular potassium precipitated by changes in blood sugar, body water volume, and insulin are contributing factors of skeletal muscle cramps.

In my personal experience, nocturnal cramping has occurred at around an hour or two before my usual awakening time, and a few days after restarting a ketogenic diet.

Why after restarting a ketogenic diet? I assume my kidneys, liver, glands, brain, etc. are all functioning normally. While off the ketogenic diet, my serum glucose and insulin were higher and my potassium store was likely lowered. I use salt with my food and drink plenty of water (mostly as coffee or tea), so my serum sodium may be slightly higher along with the lower serum potassium. Of course, after restarting a ketogenic diet, my serum glucose and insulin are minimized, and I lose weight from burning some stored fat. The weight loss is attributed to excreting the products of fat oxidation, which are carbon dioxide and water. I do not expect this extra water to significantly affect body water volume, except, there may be sufficient volume change during sleep to temporarily dilute serum potassium. Also, during periods of minimal insulin, serum potassium increases as cellular potassium decreases, and serum sodium decreases as cellular sodium increases.

Why does cramping occur at night? What is happening with insulin at night while sleeping? Serum cortisol changes with the circadian rhythm. It is highest in the morning, as it is the hormone that signals the body to produce more glucose in preparation for the morning awakening. Naturally, cortisol is lowest during sleep and increases with the approach of the morning awakening. Insulin mirrors cortisol as the pancreas releases more insulin in response to increased blood glucose.

Body temperature decreases during sleep (at night assumed), lowest in the early morning, and increases with increasing cortisol and glucose production. The temperature change from lowest to the time of cramping onset is only a fraction of a degree, but it may be sufficient to increase water volume and dilute serum potassium slightly.

Another effect of increasing cortisol is to signal all cells except for the brain and central nervous system to become temporarily insulin resistant regarding glucose. It is not clear how insulin resistance affects serum or cellular potassium, but insulin resistance is consistent with cramping (in type 2 diabetics).

The exact mechanism of skeletal muscle cramping is not entirely clear. However, it is clear that low serum potassium occurs in the presence of serum glucose, insulin, and insulin resistance; a ketogenic diet is suggested to ameliorate hyperglycemia and hyperinsulinemia; supplemental potassium helps to resolve hypokalemia and skeletal muscle cramping; and, hypomagnesia is causative of hypokalemia and correction of serum magnesium deficient with supplemental magnesium is necessary prior to correction of serum potassium deficit. The goal is several-fold: lower blood glucose and insulin, replete the magnesium store, replete the potassium store, deplete the sodium store, and correct the potassium to sodium ratio. 

In my personal experience, a few days of magnesium and potassium supplementation with ordinary salt and water intake is sufficient to resolve nocturnal cramping after restarting a ketogenic diet. 



¹ Ballout R. A., and Arabi A. Painful and Prolonged Muscle Cramps following Insulin Injections in a Patient with Type 2 Diabetes Mellitus: Revisiting the 1992 Duke Case. Frontiers in endocrinology, 8, 243. 2017. https://doi.org/10.3389/fendo.2017.00243

² Rosanoff A, Weaver CM, Rude RK. Suboptimal magnesium status in the United States: are the health consequences underestimated? Nutr Rev. 2012 Mar;70(3):153-64. https://doi.org/10.1111/j.1753-4887.2011.00465.x

³ Guerrera MP, Volpe SL, Mao JJ. Therapeutic uses of magnesium. Am Fam Physician. 2009 Jul 15;80(2):157-62. PMID: 19621856.

⁴ Garrison SR, Korownyk CS, Kolber MR, Allan GM, Musini VM, Sekhon RK, Dugré N. Magnesium for skeletal muscle cramps. Cochrane Database Syst Rev. 2020 Sep 21;9:CD009402. https://doi.org/10.1002/14651858.CD009402.pub3

⁵ Ahmed F, Mohammed A. Magnesium: The Forgotten Electrolyte—A Review on Hypomagnesemia. Medical Sciences. 2019; 7(4):56. https://doi.org/10.3390/medsci7040056

⁶ Viera, AJ, & Wouk, N. Potassium Disorders: Hypokalemia and Hyperkalemia. American family physician, 92(6), 487–495. 2015. https://pubmed.ncbi.nlm.nih.gov/26371733/

⁷ Rondon-Berrios H, Argyropoulos C, Ing TS, et al. Hypertonicity: Clinical entities, manifestations and treatment. World J Nephrol. 2017;6(1):1-13. https://doi.org/10.5527/wjn.v6.i1.1

⁸ Blaine J, Chonchol M, and Levi M. Renal Control of Calcium, Phosphate, and Magnesium Homeostasis. CJASN Jul 2015, 10 (7) 1257-1272. https://doi.org/10.2215/CJN.09750913

⁹ Huang CL, and Kuo E. Mechanism of Hypokalemia in Magnesium Deficiency. JASN Oct 2007, 18 (10) 2649-2652; https://doi.org/10.1681/ASN.2007070792


Medical Disclaimer: This article is not meant to replace the dogma of the medical profession nor is it intended to provide medical advice. Medical doctors and other health professionals provide advice on medical treatments but many do not recommend nor even mention alternative treatments. In order to make an informed decision, the patient or surrogate is burdened to search and learn about alternative treatments and to compare benefits and risks with the recommended treatment. This article presents the author's opinion on information that is relevant to health which was derived from authentic sources, published research, clinical evidence, anecdotal reports, as well as the author's personal experience and knowledge. It is intended for the self-directed learner who seeks a better understanding of health information through another opinion.