Most keto advice about leg cramps stops at “take magnesium.” That’s not wrong, exactly. It’s just embarrassingly incomplete.
Leg cramps on keto are almost never caused by a single deficiency. They’re usually a convergence of two or three things happening at once: fluid shifts, electrolyte losses that go beyond magnesium, and sometimes a movement pattern issue that keto itself didn’t create but suddenly made worse. Getting rid of them means understanding which combination you’re dealing with.
I’ve worked with enough clients to see every variation. The woman who fixed her cramps in four days with potassium. The guy who spent three months cycling through magnesium supplements while his sodium intake was the actual problem. The athlete who needed all three electrolytes plus more food. None of them got the right answer from a single article telling them to “increase your electrolytes.”
- Keto triggers rapid fluid and sodium loss in week one, pulling potassium and magnesium with it, this is the primary cramp driver for most beginners.
- Magnesium alone fixes cramps for some people, but potassium and sodium deficits are just as common and frequently overlooked.
- Most people need 300-500mg magnesium, 1,000-3,500mg potassium, and 2,000-4,000mg sodium daily on keto, significantly more than standard dietary guidelines.
- Nighttime cramps specifically often point to magnesium glycinate taken before bed (400mg) rather than morning dosing.
- Hydration matters, but drinking more water without replacing electrolytes can make cramps worse, not better.
What Keto Actually Does to Your Electrolytes
When you cut carbohydrates below roughly 50 grams a day, insulin drops. Lower insulin signals the kidneys to excrete sodium. This is the “keto flush” people talk about. In the first week or two, you can lose several pounds of water weight, which sounds great until you realize you’re also flushing significant amounts of sodium, potassium, and magnesium along with it.
Here’s where it gets counterintuitive: the cramps most people blame on magnesium in week one are often primarily a sodium problem. Sodium is the main electrolyte that controls fluid balance in your blood. When you lose it fast, your body pulls fluid from muscle tissue to compensate, and that’s when you get the 3am calf cramp that makes you yelp.
I spent probably two years telling clients to start with magnesium before I started tracking their sodium intake more carefully. Embarrassing, in retrospect. The clients who were salting their food aggressively and drinking broth were having far fewer early cramps than those eating “clean” keto meals with no added salt.
Potassium gets less attention than it deserves. You need roughly 4,700mg a day according to the National Institutes of Health, and most people on keto don’t get close to that because they’ve cut out the standard potassium sources: fruit, starchy vegetables, beans. Avocado, salmon, and leafy greens will get you some of the way there, but not all the way.
The Real Breakdown: Which Electrolyte Is Actually Missing
The honest answer is: probably several. But they don’t all cause identical symptoms, and paying attention to the pattern helps.
Sodium deficiency tends to cause cramps that come with headaches, brain fog, and fatigue. You feel genuinely awful, not just crampy. Potassium deficiency produces more widespread muscle weakness and cramps that span multiple muscle groups, not just your calves. Magnesium deficiency tends to be the classic nighttime calf cramp, the kind that wakes you up and won’t release for a full minute while you frantically flex your foot.
Here’s a rough guide to what the research supports on daily targets for people actively doing keto:
| Electrolyte | Standard RDA | Keto-Adjusted Target | Good Food Sources | Supplement Option |
|---|---|---|---|---|
| Sodium | 2,300mg | 3,000-5,000mg | Broth, salt, pickles | Not needed if salting food |
| Potassium | 4,700mg | 3,000-4,700mg | Avocado, salmon, spinach | No Salt / Nu-Salt (KCl) |
| Magnesium | 310-420mg | 300-500mg elemental | Pumpkin seeds, dark chocolate | Glycinate or malate form |
| Calcium | 1,000mg | 1,000mg (less altered) | Dairy, sardines | Less commonly needed |
The potassium number is intentionally a range. Some people on keto eat enough greens and salmon to hit 3,500mg from food alone and do fine. Others, especially those eating very meat-forward keto with minimal vegetables, fall closer to 1,500mg and feel it in their legs within weeks.
A concrete scenario that plays out regularly in my practice: Client doing carnivore-adjacent keto, eating mostly beef, eggs, and cheese. Cramps every night for six weeks, tried magnesium glycinate at 400mg before bed, slight improvement. Added a teaspoon of No Salt to their water bottle daily (roughly 1,300mg potassium) and the cramps stopped within five days. Food journal showed potassium intake had been hovering around 1,700mg.
Magnesium: The Form Actually Matters
This deserves its own section because the number of people taking magnesium oxide is too high. Oxide is the cheapest form, it’s what’s in most grocery store supplements, and it has about 4% bioavailability. You’re essentially paying for something your body mostly ignores.
The forms worth using: magnesium glycinate (well absorbed, gentle on the gut, best for sleep and cramping), magnesium malate (good absorption, slightly more energizing, useful if fatigue is also an issue), and magnesium citrate (decent absorption but can cause loose stools at higher doses). Avoid oxide. Avoid anything that doesn’t specify the form on the label.
Dosing: 300-400mg elemental magnesium before bed is a reasonable starting point for cramp prevention. “Elemental” is the actual magnesium content, not the compound weight. A capsule labeled “500mg magnesium glycinate” may contain only around 50-60mg elemental magnesium. Read the supplement facts panel, not the product name.
Products I’ve recommended to clients currently (as of August 2026): Doctor’s Best High Absorption Magnesium (glycinate/lysinate chelate, around $18-22 for 240 tablets on Amazon) and NOW Foods Magnesium Glycinate ($20-26 for 180 capsules). Both are legitimately well-absorbed and reasonably priced. The fancy $45 options from boutique keto brands aren’t doing anything different.
[Affiliate note: this site may earn a commission on Amazon purchases.]
Hydration Is Not What You Think It Is
Drink more water is standard cramp advice. It’s also partially wrong for the keto context.
When you’re depleted in sodium, drinking plain water dilutes what little sodium you have left. Your cells can’t hold the fluid properly, you excrete even more sodium through urine, and you can end up with something approaching hyponatremia if you push it far enough. This is why some keto beginners who are dutifully drinking their eight glasses a day and still cramping badly are actually making things worse with every glass.
The fix isn’t less water. It’s electrolyte-balanced water. A pinch of salt per liter (roughly 500mg sodium), or one serving of an electrolyte product that actually contains sodium, not just a token 35mg that exists for label decoration.
Products currently worth buying: LMNT packets run about $45 for 30 servings, which is pricey but they’re one of the few that include meaningful sodium (1,000mg per packet). Redmond Re-Lyte is comparable in sodium content at a slightly lower price point. The mainstream sports drinks like Gatorade Zero have 160mg sodium per bottle, which is too low to matter much. Liquid IV is mostly sugar, not relevant here.
The timing signal that took me too long to act on: clients whose cramps happened specifically within an hour of drinking a large glass of plain water. Once I started connecting that pattern, the sodium dilution mechanism became obvious.
Why Some People Cramp Months In, Not Just at the Start
Beginners assume electrolyte issues resolve after the initial adaptation phase. Sometimes they do. Sometimes they don’t, and there are a few reasons why cramps persist beyond the first month.
One is that the person simply isn’t maintaining their electrolyte intake consistently. They hit their targets for two weeks, feel better, stop supplementing, and the cramps return a month later. Keto requires ongoing attention to electrolytes, not a one-time fix.
Another is exercise intensity. Someone who ramps up their training three months in is sweating more and losing more sodium and magnesium through sweat than their current intake replaces. Magnesium loss through sweat is real and measurable, roughly 4-8mg per liter of sweat depending on the individual.
The third cause is trickier: actual low carbohydrate intake combined with inadequate caloric intake. Very low calorie keto diets accelerate muscle protein breakdown, and muscle that’s being catabolized is more prone to cramping. I can’t give you a precise number on how common this is in keto dieters specifically, because I don’t have solid data on it, but clinically I see it in clients who are pairing keto with aggressive calorie restriction.
Scenario: Client, three months into strict keto, began training for a half marathon. Cramps started appearing mid-run around week two of training. Was taking 300mg magnesium glycinate nightly. Increased sodium to 4,500mg daily, added 400mg potassium pre-run via Nu-Salt, bumped magnesium to 400mg. Cramps resolved within 10 days and didn’t return through the rest of her training cycle.
Sources
- National Institutes of Health Office of Dietary Supplements: Magnesium, potassium, and sodium fact sheets with RDAs and upper limits.
- Volek JS, Phinney SD (2012): “The Art and Science of Low Carbohydrate Performance.” Detailed discussion of electrolyte physiology during carbohydrate restriction.
- Felig P, et al. (1969): “Muscle glycogen and glucose turnover in prolonged starvation.” Early data on renal sodium excretion under low-carb conditions.
- Rosanoff A, Weaver CM, Rude RK (2012): “Suboptimal magnesium status in the United States: are the health consequences underestimated?” Nutrition Reviews. Establishes widespread baseline magnesium insufficiency, which keto exacerbates.
- Phinney SD (2004): “Ketogenic diets and physical performance.” Nutrition and Metabolism. Covers adaptation physiology including electrolyte losses in trained athletes.
Photo: Konstantin Mishchenko via Pexels
This article is for general informational purposes only and does not constitute medical or dietary advice. Always consult a licensed healthcare provider or registered dietitian before making significant changes to your diet, especially if you have a medical condition.
Diana Walsh





