How long before bed to stop drinking coffee? The most defensible figure in the literature is modelled rather than measured. A 2023 meta-regression estimated that a 107 mg coffee would need to be consumed at least 8.8 hours before bed, and a 217.5 mg pre-workout dose at least 13.2 hours before bed, to avoid reductions in total sleep time. Those are model outputs tied to specific doses, not tested thresholds and not a curfew. The usable version is a subtraction you run against your own bedtime and your own cup, and the spread between people is wide enough that any single clock time is a poor personal instruction.
It is 16:40 on a Thursday. The change window opens at 21:00, the runbook is nine steps long, and you make another coffee because that is what 16:40 is for. Somewhere at the back of your head sits a rule from a wellness newsletter: nothing after 2pm. You ignore it. At 00:40 you are staring at the ceiling doing sleep arithmetic, and the rule comes back to taunt you.
The 2pm rule is not wrong so much as flattened. The rounding threw away the parts that carry the information: the dose, the spread between people, and what the number was measuring in the first place. Here is the unflattened version, and then the thing the timing conversation never reaches, which is what caffeine does not restore after a bad night.
What the pooled numbers actually show

The best current summary is a 2023 systematic review and meta-analysis of 24 studies in Sleep Medicine Reviews. Pooled, caffeine cut total sleep time by roughly 45 minutes and sleep efficiency by about 7%. It added around 9 minutes to sleep onset and about 12 minutes of wake time after people had already fallen asleep. Deep N3 and N4 sleep went down; the proportion of light N1 went up. REM duration showed no significant change.
Notice which number is smallest. Sleep onset latency, nine minutes: the lying-awake part everyone fixates on. The 45 minutes of lost sleep is mostly not you failing to drop off. It is the night going shallower and more fragmented around you while you are unconscious and unable to file a bug report about it.
A caveat has to travel with those figures. They are pooled averages across studies with different protocols and participants with different caffeine histories, and habitual drinkers may show partial tolerance to caffeine’s sleep effects. If you have had four cups a day for a decade, the pooled 45 minutes is not a prediction about your Thursday. It is the centre of a wide, messy distribution you are somewhere inside, and the pooled data cannot say where.
Where “8.8 hours” comes from, and what it is not
The same paper ran a meta-regression on timing, and this is the bit that gets laundered into cutoff rules. The later in the day the caffeine, the larger the hit to total sleep time. From that relationship the authors modelled the 8.8-hour and 13.2-hour figures above.
Put the emphasis in the right place. Those hours are outputs of a statistical model fitted across heterogeneous studies. Nobody ran a trial that dosed people at 8.8 hours before bed, found sleep intact, then dosed at 8.5 and found it broken. It is an extrapolation from a regression line, welded to a specific dose. Change the dose and the number moves, which is the whole reason the paper reports two. And the model was steering around reductions in total sleep time, not the shift from deep sleep to light. “8.8 hours” is not a threshold below which nothing happens.
Take it at face value for a moment, purely as an illustration of how the subtraction behaves. Count back 8.8 hours from a midnight bedtime and the 107 mg coffee lands at about 15:12. Shift the bedtime and that time shifts with it, which is the point: the hours are the input, the clock time is only ever an output. And 107 mg is a modest dose. The FDA’s rough conversion puts 400 mg at four to five cups, which by my arithmetic on that loose figure puts 107 mg somewhere near a single cup. The 16:40 coffee that is really a 300 ml pour from the office machine is not the thing the model was describing.
How long before bed to stop drinking coffee: the arithmetic you can run

Half-life is the more useful mental model, because you can run it in your head and because it forces the spread on you. A review of caffeine pharmacokinetics puts the typical elimination half-life at around four hours, and documents how far that shifts between people: roughly 3.5 hours in smokers against 6 hours in non-smokers, and as long as 10.5 hours in the final weeks of pregnancy.
Take a dose at 16:00 and ask what is left at midnight. The fractions below are my own exponential-decay arithmetic on that published mean and range, not a finding from the paper. We flag derived numbers as derived, and how we research explains why:
- At the typical four-hour half-life: about a quarter of the dose is still circulating.
- At 3.5 hours, the figure reported for smokers: about a fifth.
- At 6 hours, the figure reported for non-smokers: about two fifths. You are going to bed on a good share of an afternoon coffee.
- Same drink, same clock, same room. Different person.
That spread is not noise. Clearance is dominated by the hepatic enzyme CYP1A2, and CYP1A2 activity varies substantially between individuals, which is why reported half-lives run from a couple of hours to well over ten. No universal cutoff time survives that range. Any article that hands you one has quietly assumed you are average.
It does not follow that you should go and buy a test. Consumer genotyping will not hand you a personal curfew; carrying some variant does not convert into a clock time you can act on. What I would do instead is boring and free, and I am offering it as reasoning rather than as a validated protocol, because no study in this evidence base tested it: hold your bedtime steady, move the last dose of the day earlier in small steps, and pay attention to what your nights do. That is a personal experiment with an n of one, which is a real limitation, but it is measuring the thing you actually care about.
The part caffeine does not buy you

Now the question underneath the question. You are not really asking when to stop drinking coffee. You are asking whether you can caffeine through a bad night and still be trusted with prod.
One study speaks unusually directly to that. Stepan, Altmann and Fenn kept participants awake for an entire night, then gave them 200 mg of caffeine. On a vigilant attention task, the classic stay-awake-and-react measure, caffeine restored performance. On place-keeping, the cognitive-control process that lets you work through a multi-step procedure without losing your position in it, it did not significantly help most participants, though it did reduce the number who failed to hold criterion accuracy. Caffeine repaired the deficit those participants could feel and left the one they could not largely where it was.
The limits are real and worth stating plainly. A single night of total sleep deprivation, in a lab, one 200 mg dose, results reported as group averages. It does not describe six hours of sleep. The same selectivity has not been established for ordinary short sleep, or for the chronic partial restriction that is the actual pattern on most on-call rotations. Anyone telling you this study proves your 3am deploy is compromised is overreaching, and so is anyone telling you it proves the opposite.
What it does establish is the shape of the benefit: selective, not general. From here on this is my reading rather than the paper’s. If the benefit really is selective in that direction, then feeling alert is a poor instrument for judging whether you are reliable at procedures, because subjective sharpness is the exact channel caffeine restores. The gauge and the thing you want to measure have come apart.
So the operational conclusion I draw (again, my inference, and one the study does not license, since it did not test short nights) is to stop treating “I feel fine” as a green light for irreversible steps after a bad night. Read the runbook line by line rather than from memory. Get a second pair of eyes on anything with a destructive verb in it. The same discipline is worth applying when an assistant wrote the code, where confidence tends to outrun accuracy in a similar way. Those controls cost minutes, and unlike your own judgement, they do not depend on how awake you feel.
The total-dose guardrail, and where this advice stops

Timing is one axis; total daily load is the other. The FDA cites 400 mg a day, roughly four or five cups, as an amount not generally associated with dangerous negative effects in healthy adults, while noting that tolerance varies with body weight, medication and individual sensitivity. That conditionality is part of the guidance, not a footnote to it.
And it applies to healthy adults. If you are pregnant, have a cardiac arrhythmia or another heart condition, live with an anxiety disorder or reflux, or take medication that may interact with caffeine, none of this article is written for you. TorpidLife cannot assess your situation and does not give individual medical advice. See our medical disclaimer, and have that conversation with a clinician who knows your history.
One last piece of context, handled carefully, because it is routinely abused. The CDC advises adults aged 18 to 60 to sleep at least seven hours a night, and short sleep is associated in observational data with outcomes including obesity, diabetes, high blood pressure, coronary heart disease, stroke, frequent mental distress and all-cause mortality. Those are population-level associations with short sleep duration. They are not demonstrated consequences of an afternoon coffee. Nobody has shown that your 16:40 flat white causes any of them, and anyone drawing that line for you is selling something. The seven-hour figure earns its place here for a duller reason: it is why a 45-minute dent is worth two minutes of thought rather than a shrug.
Common questions
How long before bed should I stop drinking coffee?
The best answer available is a modelled one, not a measured one. The 2023 meta-regression implies at least 8.8 hours for a 107 mg coffee and at least 13.2 hours for a 217.5 mg dose, if the goal is avoiding reductions in total sleep time. Treat those as dose-linked model estimates rather than validated cutoffs. Count backwards from your own bedtime instead of adopting a fixed clock time, and expect your real number to sit either side of the model’s, because half-life varies so widely between people.
Is 2pm the right cutoff or not?
It is a serviceable default only if you sleep around 23:00 and drink modest single doses. A 01:00 bedtime pushes the same logic later; a doubled dose pushes it considerably earlier. The failure of “2pm” is not the hour it picks, it is that it hides both variables.
I have drunk coffee daily for fifteen years. Do the 45 minutes apply to me?
Probably not as stated. The meta-analysis pooled studies with differing habituation, and habitual consumers may show partial tolerance to caffeine’s sleep effects, so a long-term daily drinker’s real figure may be smaller than the pooled average. Smaller is not zero, and the pooled data cannot tell you where you sit.
Does caffeine ruin REM sleep?
Not according to the pooled evidence: the meta-analysis found no significant effect on REM duration. The measurable architecture change was elsewhere: less deep N3 and N4 sleep, and a greater share of the night spent in light N1.
Can I caffeine my way through a bad night before a release?
Partly, and not in the way you would want. In one lab study, after a night of total sleep deprivation, 200 mg of caffeine counteracted the impairment in vigilant attention but did not significantly help place-keeping for most participants, though it did cut the number who failed to hold criterion accuracy. That study looked at total deprivation, not a merely short night, so do not over-apply it, but nothing in the evidence supports assuming that feeling alert means procedural accuracy came back with it.
What to do with this
Delete the 2pm rule and replace it with a subtraction. Fix your bedtime, know roughly what your dose is, subtract, then watch what your nights do as you move the last cup earlier. The published range of half-lives is wide enough that the population mean is nearly useless as a personal instruction, which is the reason to run the subtraction yourself rather than inherit someone else’s hour.
Then keep the two questions apart. “Will this coffee cost me sleep tonight” is pharmacokinetics, and it has a rough, honest answer. “Am I safe to run this migration at 03:00” is a different question, and the alertness you can feel is not the variable it turns on. Coffee is fine. It just does not do everything you have quietly been counting on it to do at 3am.

Leave a Reply