Do you experience crippling leg cramps on your low-carb keto diet? Do you awaken in the night with a sense of dread as the unmistakable tightening starts to creep over toes, a calf muscle, or a foot arch?

Fortunately, leg cramps don’t happen to everyone on a low-carb, keto diet. However, if they do happen to you, that early tingling can suddenly harden into a full-blown, agonizing charley horse that sometimes feels like it will tear the muscle off the bone.

The muscle soreness can last for days. Some people may experience legs cramps on a nightly basis, contributing to severe insomnia and potentially increasing their night-time risk of falling.1

If this happens to you, this guide will help. We’ll go into six key things to explore to get leg cramps under control.

Nocturnal leg cramps are a common complaint in medical practices even among people not eating a low-carb or ketogenic diet. It is difficult to assess exactly how many people suffer from leg cramps, but some estimates are as high as 33% of all adults over age 50.2

Among low-carb and keto eaters leg cramps may be even more prominent. While exact numbers are hard to come by, increased frequency of leg cramps is generally considered a common side effect of the diet.3

Here are the six key things to know to kick your leg cramps to the curb:

1. Magnesium deficiency may be a problem for many

Some researchers believe that most leg cramps arise because of a magnesium deficiency.4 However, there is a lack of quality evidence to support this theory.5

Magnesium is a crucial mineral that the body needs for more than 300 enzymatic reactions, including muscle contractions and neuro-muscular conduction of signals.6

“Magnesium calms muscles (including the heart), nerves and the brain. When magnesium levels fall in these organs, they get ‘twitchy’,” explain Dr. Stephen Phinney and Jeff Volek in their book The Art and Science of Low Carbohydrate Living.7

As they note in their book, cramps during or after exercise or at night may be a sign that your body has a magnesium deficiency.8 However, that has been difficult to prove in scientific studies.

In part, this may be because testing for magnesium deficiencies can be challenging and unreliable. Standard blood tests measure serum magnesium, but experts suggest what really matters is cellular magnesium levels, and those may be low well before it shows up on a blood test.9 Therefore, it is possible that someone may test “normal” for their magnesium level but still be deficient on a cellular level.

In addition, subclinical magnesium deficiency — meaning the deficiency is not yet showing outward symptoms — may be a significant issue in the population at large. It is estimated that almost 50 percent of the US population does not meet the daily dietary requirement for magnesium.10

So why can low-carb eating suddenly bring on leg cramps or make them worse? It may be because a low-carb keto diet shifts the balance of our electrolytes, particularly salt.11 That electrolyte shift can unmask a pre-existing magnesium deficiency, explains Dr. Jay Wortman, a Vancouver physician who experienced his own battle with crippling leg cramps when he first started a low-carb diet almost two decades ago. He solved the problem by magnesium supplementation.12 As well, cooking methods can reduce the amount in food even more.13

The following tricks may help you get more magnesium from your food, although formal studies are lacking: don’t overcook vegetables, use the drippings from roasted meat, make bone broth or keep the water that vegetables have been cooked in and use it for soups or sauces.14

Supplementing magnesium

Starch structureAs long as you have normal kidney function, oral supplementation of magnesium is the most reliable way to ensure you are getting enough.15 But it can take some work to find the supplement that works best for you.

There are several types of oral magnesium available, including magnesium aspartate, magnesium citrate, magnesium chloride, magnesium lactate, magnesium malate, magnesium taurate, magnesium gluconate, magnesium glycinate and magnesium oxide.

Magnesium supplements can cause diarrhea for some people, which can reduce the amount of magnesium absorbed. New animal research suggests the most easily absorbed versions, that may be the least upsetting to the digestive tract, are glycinate, malate and taurate — but those GI results can be very individual and an extensive review of magnesium absorption showed inconsistent results.16

Magnesium citrate and magnesium oxide are routinely used as “osmotic laxatives” — meaning they pull water from the intestine wall — and so are most likely to trigger diarrhea.  You may have to experiment to find the type you tolerate best.17 Of course, for individuals who suffer from constipation on a low-carb keto diet, the laxative effect of magnesium may be a welcome side effect.

Topical magnesium oils and lotions, or magnesium sulfate (Epsom salts) that are absorbed through the skin are easier on the stomach — but there is great debate in the medical literature whether topical applications of magnesium can be absorbed in enough strength to actually improve significant deficiencies.18 If you can’t tolerate oral supplements, however, topical magnesium products may be worth a try to see if they help your leg cramps.

Here is another factor to consider: the quality and effectiveness of commercial magnesium formulations vary significantly., a company that independently tests supplements to verify label claims, tested more than 40 magnesium formulations and found many supplements contained less magnesium than claimed or did not disintegrate properly after being swallowed, reducing the amount absorbed. (As well, some supplements even contained lead.) Drs. Phinney and Volek caution against using magnesium gluconate on a low-carb diet, due to its high carbohydrate content.19

If you’ve been taking magnesium regularly but it has not been solving your leg cramp problem, you may not be absorbing enough and may need to adjust the type of magnesium or the way you take it.20

How to get more magnesium

Here are our best tips for upping your body’s magnesium stores.

  • Take a slow-release magnesium supplement for at least 20 days: Drs. Phinney and Volek have created a protocol for leg cramps in which you take three slow-release magnesium tablets a day for 20 days.21 Slow release formulations include Mag64, Slow Mag, or Mag-Delay. (These formulations are available in the US, but sometimes not in other countries. Ask your local pharmacist if there is a slow release version in your region.) If the cramps return after a month of slow-release supplementation, do the protocol again, and then continue taking one pill a day. If cramping still continues, take two slow-release pills a day in perpetuity.
  • Take daily one-third the dose of milk of magnesia: Dr. Eric Westman recommends that his patients take a small daily dose of milk of magnesia (magnesium hydroxide), about 1 teaspoon a day, which is one-third the dose used for its laxative qualities. This small amount will not cause most people to have diarrhea but will up the amount of magnesium you absorb.22
  • Try absorbing magnesium through the skin: A regular bath with Epsom salts (magnesium sulfate) is a relaxing way to soothe sore muscles and may help increase your magnesium stores, in addition to oral supplementation. You can also try massaging magnesium infused oils or lotions into the skin. As noted above, however, research to-date has not proven the effectiveness of this.23
  • Drink mineral water with magnesium: Some mineral waters have very little magnesium, but a few brands are very good sources of elemental magnesium which is very easily absorbed and easy on the stomach. A mineral water is considered to be a source of magnesium if it has a magnesium content of at least 50 mg per liter.24 Two widely available German mineral waters are particularly high in magnesium, Apollinaris, with 130 mg/L and Gerolsteiner, with 108 mg/L. Check the labels of other mineral waters available in your region for their magnesium levels.

For many people on a low-carb or keto diet, magnesium supplementation appears to be enough to solve the cramps.25 Drs. Phinney and Volek note that some people may need to supplement for up to a year to solve a significant magnesium deficiency. And some people may need to supplement for life.26

If regular magnesium supplementation is not eliminating your leg cramps, pay attention to the following other factors.

2. Salt

The electrolyte shifts that happen on a low-carb diet are largely the result of the loss of salt through urination. When the consumption of carbohydrates is low, the body releases less insulin, which causes the kidneys to excrete more salt in the urine.27

So, point of fact, you may need more salt when you eat a low-carb ketogenic diet, as Diet Doctor has discussed in other posts.

Many people coming to a low-carb keto diet have not only heeded nutritional advice to avoid fat for years, they have also avoided salt for years. You may have to be really conscious of consuming more salt, especially on hot days or after working out. Don’t be afraid to add salt to your food and try adding a few shakes of salt to a glass of water or drink salted bone broth regularly.28

Drinking pickle juice is another common recommendation to ward off leg cramps caused by salt depletion. That’s what US tennis player Francis Tiafoe did to prevent cramping during the blistering hot 2019 Australian open. While there have been more than a dozen studies on the use of pickle juice for cramp prevention published in athletic journals over the last decade, its effectiveness and impact is still under debate and investigation.29

3. Potassium may help, too

Muscle cramps, muscle twitches and rapid heartbeats can all be a symptom of low potassium, notes Franziska Spritzler, low-carb dietitian and Diet Doctor nutrition expert. In her guide on electrolyte supplementation she notes that when salt is lost from the body at a higher rate due to low-carb eating, the kidneys may respond by increasing sodium absorption and excreting more potassium into the urine in an attempt to maintain biochemical balance.30

Increasing your consumption of high potassium foods like avocado, Swiss chard and spinach can often be all that is needed to increase your potassium levels.31 Most people can get adequate amounts of intake solely from the food they eat.

Potassium supplements can be taken, too, but there is a risk you can take too much. Most multivitamins have about 80 mg of potassium per pill, but you can buy potassium on its own. Supplement makers by FDA regulation, however, are not allowed to make formulations with more than 99 mg of potassium per pill — that is why the pills are so tiny.32

As cardiologist Dr. Bret Scher notes, taking too much potassium can cause health issues, especially for those with kidney disease, such as potentially dangerous heart rhythms and skeletal muscle dysfunction. Common side effects of even small doses of potassium supplements are nausea and digestive upset.33

“Those who have altered kidney function need to be most careful with potassium supplementations and should only do so under medical guidance,” advises Dr Scher.

For the rest of us, potassium supplementation is mostly safe, but we can still get into trouble by over supplementing. Says Dr. Scher: “The best bet is to start with no more than 99 mg per day, but if you feel you need more, get a blood test to see where you are at and supplement to target a high-normal level (around 4.5 mg/dl).”

When Dr. Wortman found that his leg cramps were coming back, he not only restarted the Phinney-Volek slow-release magnesium protocol, he chose to replace potassium in a simple, inexpensive way. He buys “lite” salt substitutes from the grocery store aisle, in which sodium chloride is mixed 50 percent with potassium chloride. A few shakes of lite salt and he gets all the extra potassium he needs. Be careful to use only tiny amounts of lite salt, however, as lite salt provides 350 mg per quarter teaspoon.


Do you need electrolyte supplementation on a keto diet?

Guide Meat, fish, eggs, dairy, nuts and vegetables are rich in all key nutrients that your body needs on a daily basis. In some cases, however, supplementing with minerals known as electrolytes may be beneficial.

4. Dehydration or overhydration?

Some experts put dehydration as one of the top reasons people get leg cramps, especially after intense exercise, but that theory is hotly debated.34

While it is important to keep well hydrated, drinking too much water can increase salt loss and actually lead to a dangerous condition called hyponatremia — literally too little sodium. A 2016 study of hydration guidelines from exercise sites across the internet found that advice for drinking enough water during exercise to avoid muscle cramping was actually contributing to overhydration and hyponatremia for some people.35

One simple way to check if you are well-hydrated is to note the color of your urine. If it is dark yellow, you may benefit from drinking more water. If it is extremely pale, you may be drinking too much water. Another simple test is to pinch the skin on the back of your hand between your thumb and forefinger for about five seconds. Called the skin turgor test, when you release the pinched skin, it should rapidly go back into place. If it stays “tented up” or moves slowly back into position you may be dehydrated.

Still experiencing cramps after paying attention to these four tips? Okay, now we go on to proactively identifying common triggers.

5. Situational risks factors: Common triggering ‘Ts’

The research literature shows that there are common situational triggers for leg cramps.

  • Taking diuretic medications: diuretic drugs reduce blood pressure by flushing salt out of your body, taking fluid with it. These drugs can have the side effect of causing leg cramps.36 Fortunately, a low-carb diet improves high blood pressure for many people, in some cases enough to come off medication.37 If you still need to take a drug for high blood pressure, switching to another class of anti-hypertensive may help.
  • Too much sitting: A long day sitting at a desk without taking breaks to walk around, a long car ride, a long airplane flight — all of these might potentially contribute to night-time cramps. Sitting too long, especially crossing legs, tightens calf muscles. Make sure to get up regularly to move and stretch throughout the day.
  • Too much exertion: Athletic exertion is a known trigger, but why exactly it happens to only some athletes is still debated.38 If you plan to be very physically active, pay extra attention to magnesium and salt supplementation, stay well hydrated with regular water or mineral water, stretch before working out and sleeping, and perhaps enjoy an Epsom salt bath after the exercise and before bed.
  • Too-tight leg muscles: Tight calves and hamstring muscles may be more prone to cramping. Regular yoga classes, before-bed stretching and foam rolling of legs, as demonstrated in this video, can help limber up legs and may prevent cramping. A 2012 randomized trial of nightly stretching before bed found a reduction in cramping frequency in older adults who stretched.39
  • Too much wine: Research in France has found that even drinking alcohol once a week might increase the risk of leg cramps almost seven times for adults over the age of 60.40 Alcohol consumption, particularly red wine, is a known anecdotal trigger for many people.
  • Travel: Perhaps because travel often entails a lot of sitting in planes or cars, unusual periods of exertion or activity, higher risks of dehydration and potentially more holiday alcohol consumption than usual, travel may be a common trigger for many. Paying attention to salt intake, magnesium levels, adequate hydration and stretching may be especially key for avoiding leg cramps during times of travel.

6. Caffeine may be a trigger for some

If you are a coffee lover and all these steps above still have not reliably solved your leg cramp issue, here is one more thing to try: cut back or eliminate, for a while, your caffeine consumption. It just might help.

Coffee is a known muscle stimulant. Studies have found that it increases the contraction force of skeletal muscle.41 Over the last two decades many studies have investigated caffeine’s role in improving muscle strength, increasing endurance and enhancing performance in competitive athletes.42

A number of studies have found, however, a great deal of individual variation, likely related to genes. While some may find it improves the performance of their muscles, others can find it undermines their muscle function.43 Caffeine is also a natural diuretic and causes increased salt wasting in the kidneys and other mineral losses.44

While good studies are non-existent, a 2007 case study found that removing coffee from the diet of a 54-year-old man afflicted with nightly leg cramps completely resolved them.45

Have you suffered frequent leg cramps on the keto diet? Let us know if these tips help. What works best for you?

/ Anne Mullens

  1. American Family Physician 2012: Nocturnal leg cramps [overview article; ungraded]

  2. While that statistic is not supported by strong evidence, suffice it to say that it is a common and problematic issue for many.

    BioMedical Central Family Practice 2017: Criteria in diagnosing nocturnal leg cramps: a systematic review [the estimate is mentioned, without clear support]

  3. This is based on the clinical experience of low-carb practitioners. [weak evidence]

  4. Canadian Family Physician 1996: Muscle cramps and magnesium deficiency: Case reports [anecdotal report; very weak evidence]

  5. The following Cochrane review found no benefit for muscle cramps in the general population with magnesium supplementation.

    Cochrane Database Systematic Reviews 2012: Magnesium for skeletal muscle cramps [systematic review of randomized trials; strong evidence]

  6. Nutrients 2015: Magnesium in prevention and therapy [overview article; ungraded]

  7. [book excerpt article; ungraded]

    Diet Doctor will not benefit from your purchases. We do not show ads, use any affiliate links, sell products or take money from industry. Instead we’re funded by the people, via our optional membership. Learn more

  8. This is not based on scientific studies [book excerpt; ungraded evidence]

  9. This may be why symptoms can improve for some, especially pregnant women, with magnesium supplements despite normal blood levels. However randomized controlled trials suggest that magnesium supplementation may not prevent nocturnal leg cramps in the general population. This contributes to the difficulty in diagnosing magnesium deficiency and estimating its prevalence.

    Cochrane 2012: Magnesium for muscle cramps [strong evidence]

    Family practice 2014: Effect of magnesium therapy on nocturnal leg cramps: a systematic review of randomized controlled trials with meta-analysis using simulations [strong evidence]

    Nutrients 2018: Challenges in the diagnosis of magnesium status [overview article; ungraded]

  10. USDA: What we eat in America, NHANES 2005-2006, usual nutrient intakes from food and water compared to 1997 Dietary Reference Intakes for vitamin D, calcium, phosphorus, and magnesium [observational study; weak evidence]

    Nutrition Review 2012: Suboptimal magnesium status in the United States: are the health consequences underestimated? [overview article; ungraded]

  11. To our knowledge there is no good scientific evidence for this explanation, though it makes theoretical sense. [no evidence]

  12. [anecdotal report; very weak evidence]

    Our main source of magnesium — the food we eat — may not be sufficient for our needs because of the depletion of the mineral in our soils through modern agriculture and from low levels of magnesium in processed foods. Science Direct 2016: Magnesium deficiency in plants — an urgent problem [overview article; ungraded]

  13. Journal of Nutritional Science Vitaminology 1990: Cooking losses of minerals in foods and its nutritional significance [mechanistic study; ungraded]

  14. [no evidence]

  15. American Family Physician 2009: Therapeutic uses of magnesium [overview article; ungraded]

  16. Current Nutrition and Food Science 2017: Intestinal absorption and factors influencing bioavailability of magnesium – an update [overview article; ungraded]

     Biologic Trace Element Research 2019: Timeline (bioavailability) of magnesium compounds in hours: which magnesium compound works best? [rat study; very weak evidence]

  17. NIH Office of Supplements: Fact sheet magnesium for consumers [overview article; ungraded]

  18. Nutrients 2017: Myth or reality — transdermal magnesium [overview article; ungraded]

  19. [book excerpt; ungraded evidence]

  20. This is based on consistent clinical experience of low-carb practitioners. [weak evidence]

  21. This recommendation is based on clinical experience.[weak evidence]

  22. This recommendation is based on clinical experience.[weak evidence]

  23. Nutrients 2017: Myth or reality — transdermal magnesium [overview article; ungraded]

  24. Food Nutrition Research 2017: Magnesium bioavailability from mineral waters with different mineralization levels in comparison to bread and a supplement [randomized trial; moderate evidence]

  25. This is based on the clinical experience of low-carb practitioners. [weak evidence]

  26. Since no clinical studies exist to guide us, we rely on clinical experience here. [weak evidence]

  27. American Journal of Physiology 2007: Insulin’s impact on renal sodium transport and blood pressure in health, obesity, and diabetes [overview article; ungraded]

    Diabetalogia 1981: The effect of insulin on renal sodium metabolism [overview article; ungraded]

  28. If you have high blood pressure, make sure you monitor it closely to see if it increases after adding more salt to your diet

  29. Journal of Athletic Training 2015: Plasma and electrolyte changes in exercising humans after ingestion of multiple boluses of pickle juice [non-randomized study; weak evidence]

  30. International Journal of Hypertension 2011: Insulin resistance, obesity, hypertension, and renal sodium transport [overview article; ungraded]

    Virta Health blog post 2019: The importance of managing potassium and sodium as part of a well-formulated ketogenic diet [overview article]

  31. This is based on consistent clinical experience of low-carb practitioners. [weak evidence]

  32. National Institutes of Health Office of Dietary Supplements: Potassium supplement brief [overview article; ungraded]

  33. National Institutes of Health Office of Dietary Supplements: Potassium supplement brief [overview article; ungraded]

  34. Materia Socia-medica 2018: Exercise induced muscle cramps: doubts about the cause [overview article; ungraded]

  35. The Physician and Sports Medicine 2016: Are we being drowned by overhydration advice on the internet? [overview article; ungraded]

  36. The Journal of Clinical Hypertension 2007: Muscle cramps and diuretic therapy [overview article; ungraded]

  37. Obesity Reviews 2012: Systematic review and meta-analysis of clinical trials of the effects of low carbohydrate diets on cardiovascular risk factors [strong evidence]

    Archives of Internal Medicine 2010: A randomized trial of a low-carbohydrate diet vs orlistat plus a low-fat diet for weight loss [moderate evidence]

    Cardiovascular Diabetology 2018: Cardiovascular disease risk factor responses to a type 2 diabetes care model including nutritional ketosis induced by sustained carbohydrate restriction at 1 year: an open label, non-randomized, controlled study [weak evidence]

    South African Journal of Criticial Care 2013: Low-carbohydrate and high-fat intake can manage obesity and associated conditions: occasional survey [observational study; weak evidence]

  38. Muscle & Nerve 2016: A narrative review of exercise-associated muscle cramps: factors that contribute to neuromuscular fatigue and management implications [narrative review; ungraded]

  39. Journal of Physiotherapy 2012: Stretching before sleep reduces the frequency and severity of nocturnal leg cramps in older adults: a randomised trial [randomized trial; moderate evidence]

  40. Annals of Family Medicine 2018: Association between alcohol consumption and nocturnal leg cramps in patients over 60 years old: a case-control study [observational study; weak evidence]

  41. Journal of Physiology 1984: Caffeine potentiates low frequency skeletal muscle force in habitual and nonhabitual caffeine consumer [randomized trial; moderate evidence]

  42. Journal of the International Society of Sports Nutrition 2018: Effects of caffeine intake on muscle strength and power: a systematic review and meta-analysis [strong evidence]

  43. Sports Medicine 2018: Are the current guidelines on caffeine use in sport optimal for everyone? Inter-individual variation in caffeine ergogenicity, and a move towards personalised sports nutrition [overview article; ungraded]

  44. Life Sciences 1990: Effects of dietary caffeine on renal handling of minerals in adult women [non-randomized study; weak evidence]

  45. American Journal of Medicine 2007: Caffeine and muscle cramps: a stimulating connection [case report; very weak evidence]