It’s not uncommon to get leg cramps when starting a ketogenic diet. In fact, leg cramps are one of the classic symptoms of the keto flu (a popular term for the group of unpleasant side effects that may occur when you are transitioning your body from a high-carb diet to a low-carb, higher fat, moderate protein diet). But this doesn’t mean you have to suffer through them. Here we share some of the common causes of muscle cramps on a keto diet and what you can do to get rid of them. Hint: It’s easy!
What Causes Leg Cramps on Keto
Keto-related leg cramps are typically due to an essential mineral imbalance (usually magnesium but also possibly sodium and potassium) as well as dehydration. This imbalance tends to occur only before your body begins regularly leveraging ketones for energy rather than glucose. You can experience cramps any time of day or night if you experience them at all, and you can experience them whether or not you’re aiming for weight loss on keto.
Electrolyte (Mineral) Imbalance
When you eliminate carbs from your diet, your body produces less insulin (insulin’s job is to process carbs). With far less carbs to process, your body produces (and uses) significantly less insulin. The lessening of insulin in your system triggers your kidneys to absorb less sodium, so more is released in your urine. This can trigger a sodium deficiency and a consequent electrolyte imbalance.
What exactly are electrolytes? Electrolytes are positively charged minerals that help with hundreds of processes within the body, mostly with the muscles and nerves. They’re found in pretty much all of your bodily fluids (sweat, urine, and blood). Their primary function is to push fluid in and out of the cells (aka keep you hydrated), contracting and relaxing muscles, and nerve conduction. The main electrolytes involved in keto-related leg cramps are potassium, magnesium, and sodium. (You can learn more about each of these electrolytes below.)
When you’re converting from using glucose to ketones for energy, your body first uses up all of its glycogen (glucose) stores. Glycogen is attached to water in the body, so when it begins using its glycogen stores, it frees up the excess water to be eliminated from the body through urination. This is the reason many people lose a lot of weight fast when beginning a keto diet; your stored water (bloating) is making an exit. But, this can also lead to dehydration, especially if you’re not drinking plenty of water.
Other Reasons for Muscle Cramps
There are a few other factors that might be giving you muscle cramps, including too much caffeine and exercising and not drinking enough to make up for sweating (dehydration), or sitting for too long without moving your body.
Drinking too much coffee can increase your chance of leg cramps when you start a keto diet because caffeine stimulates your muscles to contract instead of encouraging muscle tissue to relax. It’s also a diuretic, so it takes water out of your body, which can lead to dehydration and muscle cramping.
Exercising without hydrating
When you sweat you lose both water and electrolytes, which is why there’s such a big market for sports drinks (unfortunately, sports drinks aren’t keto-friendly because they’re very high in sugar).
Sitting for too long
Many people with an electrolyte imbalance get worse leg cramps at night (nocturnal leg cramps) due to a lack of movement during the day. When you aren’t moving, your muscles can get tighter and can “seize up” on you. This is why getting up and walking sometimes helps to stop a “charley horse” (leg cramp).
How to Remedy or Avoid Muscle Cramps When Starting Keto
Now that you know what causes leg cramps, what can you do to fix them or avoid getting them in the first place? We have some simple cramp prevention solutions to help you get those leg cramps under control quickly. Let’s start with the minerals.
Ensure You’re Getting Enough Potassium
Potassium controls the cell’s energy. It helps to pump energy going in and out of the cells. Potassium is a big “muscle mineral” that is involved with muscle function; it allows your muscles to fully relax, or not go into a cramp. Potassium works in harmony with the other electrolytes for muscle contraction and relaxation. So, when you are deficient you may get muscle cramps.
How can you be sure you’re getting enough potassium? Eat lots of potassium-rich foods. While some are off limits on a keto diet (Hello, sweet potatoes, watermelon, coconut water, lentils, edamame, black beans, and some whole-grain cereals), others are keto-friendly. To ensure you get potassium through diet, stick to a clean keto diet as much as possible, and try to consume some of keto-friendly, potassium-rich foods. Some of the best foods include leafy green vegetables like beet greens, swiss chard, and spinach; mushrooms; brussels sprouts; zucchini; broccoli; and asparagus. Even wild salmon and mackerel are decent sources of potassium.
Ensure You’re Getting Enough Magnesium
Magnesium is a very important (fourth abundant) mineral in your body, yet, most of us are deficient due to modern farming practices (depleted soils). You may eat a clean keto diet, high in key nutrients, such as vegetables, yet still be deficient in magnesium. Magnesium is a co-factor (helper) mineral that helps with over 300 enzymatic processes within the body. Magnesium is involved with anything nerve or muscle related and is known as the relaxation mineral.
But magnesium and calcium play together. Magnesium and calcium are teammates when it comes to muscle and nerve function. Calcium contracts muscles, magnesium relaxes them. The typical American diet is very high in calcium and low in magnesium. When you don’t get enough magnesium to balance calcium, too much calcium can get into the muscles and contract them, and there isn’t enough magnesium to relax them, so you get those dreaded cramps.
How can you be sure you’re getting enough magnesium in your diet? Like potassium, magnesium is found in clean, whole foods. Some of the best keto-friendly food sources of magnesium are hemp, spinach, avocado, swiss chard, chia seeds, and pumpkin seeds. Because you may struggle to get enough magnesium from food alone, supplements can be good sources of magnesium as well.
Ensure You’re Getting Enough Sodium
Sodium pushes fluid in and out of the cell walls and is a co-factor in muscle contraction. You need it to maintain fluid levels in and around your cells. Sodium also helps keep the balance of the other electrolytes. As we mentioned above, when you convert to keto you lose fluids and thus lose sodium. This is why many experience “keto flu” symptoms such as headache, nausea, dizziness and heart palpitations, all of which are related to sodium loss.
How can you be sure you’re getting enough sodium? We recommend adding a pinch of Himalayan salt to your water or food, especially when transitioning into keto. (Learn more about differences between various types of salt here.) This helps tremendously with your sodium levels as your body adjusts to the transition of ketones over glucose for energy.
The easiest thing you can do is drink water throughout the day. Drink at least half of your body weight in ounces of water throughout the day. For example, if you weigh 150 pounds, you will want to drink 75 ounces of water. On top of this amount, if you drink diuretics, such as coffee, increase your water daily value by 1-1/2 cups of water per cup of coffee.
If you’re physically active on keto, be sure to hydrate before, during, and after your exercise session, and add a pinch of Himalayan salt to your water. You might want to try adding mineral drops to your water, which typically contain concentrated trace minerals. Another option is to use a keto-friendly sports electrolyte powder—these are great for after exercising or sweating a lot and can be added to water or smoothies. Lots of people also swear by pickle juice, which is high in electrolytes, to relieve dehydration-related cramps.
Remember, sitting for too long can give you leg cramps too. If you sit at a desk all day every day, be sure to get up and move your body a few times throughout the day. Consider setting an alarm to walk around and stretch a bit every two hours. Stretching out before bed can help loosen any tight areas in your muscles as well, especially if you exercise.
The biggest takeaway here? Keep those electrolytes in check, and stay hydrated. If you’re struggling with painful leg cramps on the keto diet, hopefully these tips will stop them in their tracks and improve your overall well being. Regardless, if you’re trying a new diet, it’s always a good idea to check with your primary care physician or dietitian, especially if you have a preexisting medical condition.
Keto-Mojo is a participant in some affiliate programs and some of the links above will generate a small commission if you make a purchase through a product link on our site. This is at no cost to you and all proceeds go directly to the nonprofit Ketogenic Foundation [501(c)3 pending] to assist with their mission funding education and research into the ketogenic diet and lifestyle. Keto-Mojo in no way profits from these links.
1 Insulin’s impact on renal sodium transport and blood pressure in health, obesity, and diabetes. American Physiological Society. Vol.29. Issue 4.
2 The use of nutritional supplements to induce ketosis and reduce symptoms associated with keto-induction: a narrative review. PeerJ vol. 6
3 Caffeine and Muscle Cramps: A Stimulating Connection. The American Journal of Medicine, Volume 120, Issue 8
4 Does Replacing Sodium Excreted in Sweat Attenuate the Health Benefits of Physical Activity? Int J Sport Nutr Exerc Metab.
5 The Magnesium Factor. New York: Avery Books
6 Physiology, Body Fluids. In: StatPearls