How long does caffeine stay in my system? If I drink an afternoon cup or two, will it mess with my sleep?
Java lovers, you may be in for a brewed awakening.

A 2023 randomized trial published in the New England Journal of Medicine found that people who drank one or more cups of coffee each day lost on average 36 minutes of sleep compared with those who didn’t over a two-week period.
There’s a catch though: People who were assigned to drinking coffee were also more active, taking an average of 1,000 more steps – the equivalent of walking about half a mile – per day than those randomized to the no-coffee group. The researchers speculated that perhaps the boost in activity is part of why coffee has consistently been shown to have many health benefits, including maybe even for longevity.
That trade-off between energy and sleep is something many of us coffee drinkers know intimately. Miscalculate, and you can end up “tired and wired”- a miserable state of mind I was in too often during medical training, living cup to cup.
Here’s the good news: You don’t need to quit. But you may need to move up your last cup to much earlier in the day than you think. Rather than the vague advice we’ve all heard to avoid coffee “close to bedtime,” researchers now have a more specific number. A 2023 meta-analysis of 24 studies on the effect of a standard cup of coffee (about 100 milligrams of caffeine) found that for the best night’s sleep, you need to finish drinking coffee at least nine hours or so before you sleep.
So if you’re in bed by 10 p.m., your last cup should be by 1 p.m.
Oof.
My guess is that’s earlier than a lot of us have been operating. (I’m looking especially at you, my four-cups-and-counting-per-day friends). Otherwise, the study found, coffee could reduce total sleep time by 45 minutes and increase how long it takes to fall asleep – or the sleep onset latency – by around nine minutes. (And for context, sleep onset latency of less than 30 minutes is the goal.)
Why some people can drink coffee in the evening
Avoiding coffee nine hours before bedtime is a solid, general guideline, but as with anything in medicine, each of us responds a bit differently. Older studies looking at the half-life of caffeine in our systems found that it varies from two to 10 hours, depending on the individual.
Some of the variation is written in your DNA. Scientists have identified several genes involved in how quickly we metabolize caffeine and how caffeine activates our brain’s reward system. The CYP1A2 gene controls how quickly your liver processes caffeine, while the ADORA2A gene encodes an adenosine receptor in the brain, which regulates how sensitive you are to coffee’s stimulating effects. Variants in the ADORA2A gene are associated with why some people feel anxious after coffee (*raises hand*) – and why some people experience more insomnia than others after the same cup.
So that friend who’s sipping their after-dinner espresso at 9 p.m. and still sleeps beautifully? Thank (or envy) their genes.
You may assume that regular coffee drinking could build a tolerance, eventually overcoming the sleep effects. However, the data supporting this in humans is surprisingly scarce – despite being popularly believed.
How much coffee is too much coffee?
The U.S. Food and Drug Administration advises adults to consume no more than 400 milligrams of caffeine per day, and not all cups are created equal. For instance, a medium iced latte from Dunkin’ has about 166 milligrams of caffeine and a grande Nitro Cold Brew from Starbucks has about 280 milligrams of caffeine. A typical Keurig pod contains 75 to 150 milligrams per eight-ounce cup.
A randomized controlled trial in adult men found that, on average, a 100-milligram dose of caffeine consumed four hours before bedtime had little impact on sleep whereas a 400-milligram dose consumed 12 hours before bedtime had an impact. So if you crave an afternoon cup, switch to a less potent option to minimize the chances you’ll get the receipts at bedtime.
What I want my patients to know
Coffee is one of those wonderful rarities that science keeps finding reasons to love. Because it’s such a regular part of our daily lives, making some tweaks to how and when we drink it can have an outsize impact on our health in the long term. It may not just be sleep that benefits from morning coffee drinking: In one study, people who restricted their coffee drinking to the morning hours seemed to have a mortality benefit compared with those who drank throughout the day. A disrupted circadian rhythm, which plays an important role in inflammation and your immune system, is thought to be at least one possible contributor.




