Lifestyle
Insomnia in the first weeks of keto: why it happens, and what helps
Wide awake at 1 a.m. in the first week, alert as if you had espresso, and the coffee was at lunch. The night alarm, an evening routine, and when it usually passes.
"I am lying here feeling like I had an energy drink"
Nastya wrote to me on day three of keto, at one in the morning. Dinner had been ordinary. The screen was put away ahead of time. In bed, instead of sleepiness, her heart was pounding and she felt alert, as if she had just had an espresso. She had not had coffee since lunch.
"Maria, I have never had trouble with sleep. What is going on?"
I have already gone through sleep on keto as a whole in a separate piece. That one is the wide picture: how too little sleep gets in the way of keto itself, three reasons for an early jump in sleep, and a timeline of when it improves. I am not repeating that piece here. Today is one kind of insomnia, the adaptive kind, the one that arrives in the first days and weeks, and a specific evening routine that softens it.
What is actually happening: adrenaline and cortisol against low glucose
This is the mechanism that rarely gets explained in any detail, and it is a shame, because it is exactly what sat behind Nastya's "energy drink" at one in the morning.
For years the body held blood sugar steady on a constant inflow of carbohydrate. When you take that away sharply, in the first days sugar sometimes dips below the level you are used to. Especially at night, in the stretch between dinner and breakfast. That is the longest low-carbohydrate window of the day. The body does not like low sugar, and it answers it the way it answers a small alarm.
The reaction is simple and old. The liver gets an order to raise glucose in the blood right away. The hormones that carry that order are the stress hormones, adrenaline and cortisol. Picture an internal fire alarm. Noticing that the fuel is low, the body sounds the alarm and floods the blood with substances meant to wake you and mobilize you. The problem is that the alarm does not check whether it is three in the afternoon or three at night. In the middle of the night you get the same rush of alertness you would have needed to run from danger, not to sleep soundly.
Cortisol is normally high in the morning and low in the evening. That is its healthy daily rhythm. At the start of keto that rhythm is temporarily stormy. The body has not yet set up a steady production of glucose from fat, in place of glycogen stores. Until that skill is practiced, night spikes of cortisol and adrenaline happen more often than you would want.
The second reason: electrolytes
A second mechanism is running alongside this one. It is laid out in full in the piece on keto and sleep, and I will not repeat it here. I do have to mention it briefly, because without it the evening routine does not hold together.
The drop in insulin on keto makes the kidneys clear more sodium, and water, potassium, and magnesium follow. Magnesium takes part in the work of the nervous system directly, and it helps that system switch into rest. When there is not enough of it, falling asleep is physically harder, even if the stress hormones are behaving. A shortfall of electrolytes and the adrenaline spikes of the first weeks often travel together. Together they make the picture of "lying here feeling like I had an energy drink."
An evening routine: what actually helps
Specific steps, not general advice such as "sleep more."
Magnesium in the evening. Glycinate, malate, or another form, chosen for you. This is one of the more reliable steps against the night surge of unease, and against the cramps that can wake you.
Salt through the day. A shortfall of sodium in the daytime answers as restless sleep at night no less than a shortfall of magnesium. Salt food more boldly than you are used to. Add broth, or a glass of water with a pinch of salt, especially if the day was active.
Dinner that is not a hungry one. Going to bed with a light feeling of hunger in the first weeks of keto is a direct way to wake that low-sugar alarm in the middle of the night. Dinner should be satisfying, with enough protein and enough fat, not a symbolic plate of leaves.
Caffeine timing. Caffeine can keep the nervous system stirred for 8–10 hours after a cup. Against cortisol that is already unsteady in the first weeks, the effect feels sharper than usual. How many cups, and at what time, sit comfortably on keto is its own piece on keto and coffee. That piece is also honest about butter coffee, and about why an evening cup quietly undermines sleep more than it seems to.
A small evening serving of vegetables with a bit more carbohydrate. A small handful of vegetables that carry more carbohydrate, at dinner, for example braised carrots or a little pumpkin, gently smooths the night dip in sugar for some people in the first weeks. This is not grain, and it is not fruit. It is vegetables inside the keto plate, a bit more generous in the evening than usual. It is not a required step for everyone. It is a tool that works when the insomnia of these first weeks is strong.
How long this usually lasts
The good news is that this adaptive insomnia is almost always temporary, and it fits the same stretch as the rest of primary keto adaptation.
- Days 1–3: the first breaks in sleep
Electrolytes are only starting to shift. Night bursts of alertness are still rare, and not everyone gets them.
- Days 4–10: the most unstable stretch
This is where the "energy drink at three in the morning" most often shows up. Cortisol and adrenaline answer swings in sugar most sharply in this stretch.
- Weeks 2–3: a noticeable improvement
The electrolyte routine is already helping. The body holds sugar more steadily on ketones, rather than on sharp hormone jumps.
- Weeks 3–8: sleep usually comes back to normal
For most people the night alertness and the unease have fully passed by the end of primary keto adaptation.
The timing is individual. For some people it is shorter, for some a little longer. Do not compare your third night with someone else's third week.
When this is no longer adaptation
Everything above is about the temporary adaptive insomnia of the first weeks. There are situations where the evening routine will not help, and the conversation needs to be a different one.
What happened with Nastya
Nastya started with the simplest things. Salty broth at dinner, instead of a light salad, and magnesium an hour before bed. She was already drinking coffee only until lunch, so there was nothing to change there. After four days the night alertness was weaker, and after a week and a half it had almost completely passed.
"I was sure it was my character, as if I had simply forgotten how to relax," she wrote. "And it turned out to be salt and magnesium, almost absurdly simple." That is how this usually works. It is not character that fails you. It is a specific shortfall, and it can be solved.
If you want the whole picture of sleep on keto, and not only the adaptation piece, that is the separate piece on keto and sleep. For electrolytes in people who train a lot, there is a longer piece on electrolytes and training on keto.
The short version
- The adaptive insomnia of the first weeks of keto is tied to temporary swings in blood sugar at night, which the body answers with a release of adrenaline and cortisol.
- A shortfall of electrolytes, especially magnesium and sodium, amplifies that reaction and gets in the way of the nervous system switching into rest.
- The evening routine: magnesium before bed, enough salt through the day, a satisfying dinner that is not a hungry one, caffeine only through the early part of the day.
- For some people, a small portion of evening vegetables with a bit more carbohydrate, added inside the keto plate, helps.
- It usually passes over a few weeks, together with the rest of primary keto adaptation.
- Insomnia that lasts longer than two or three months, or that sits on top of an anxiety disorder, is a reason to see a clinician, not to keep a routine going on your own.
This is education, not medical care. Ketones are a fuel the liver makes from fat. If you are pregnant, nursing, have diabetes, kidney or liver disease, an eating disorder, or you give this food pattern to a child, talk with your clinician before you change how you eat.