The afternoon has a familiar dip, and most of us have a familiar answer to it. Somewhere past lunch the energy thins, attention starts to wander, and a cup of coffee is the reflex that follows. It works, more or less. Within the hour the room sharpens, the tiredness lifts, and the rest of the day feels possible again.
What the cup does not do is add anything. It borrows. Caffeine does not top up a reserve of energy so much as it quiets the very signal that was telling you to rest, and that signal does not disappear while it is quieted. It keeps building in the background, waiting. The lift is real, but it is drawn against a bill that comes due later, often in the hours you had set aside for sleep.
So the honest question is not whether coffee works. It plainly does. The question is what it works on, how long it keeps working after the cup is empty, and why a drink taken in the bright middle of the afternoon can still be in the room at midnight. This is a calm look at the pharmacology of a daily habit: what caffeine blocks, how long it lingers, and why the timing of the last cup matters more than most of us assume.
A block, not an off switch
To understand caffeine you have to start with what it stands in for. As the hours of waking pass, a molecule called adenosine accumulates in the brain. It is a natural byproduct of the day's activity, and as it collects it dampens the neurons that keep you alert, tilting the whole system gently toward sleep. This is the homeostatic drive scientists call sleep pressure, and the longer you are awake, the heavier it grows.
Caffeine works by getting in adenosine's way. Chemically it resembles the molecule closely enough to fit the same docking sites, the adenosine receptors, without switching them on. It is what pharmacologists call a non-selective antagonist, a compound that occupies all four receptor subtypes, A1, A2A, A2B, and A3, and blocks each one. The wakefulness itself is tied most closely to the A2A receptor. Because caffeine is both water- and fat-soluble and is absorbed almost completely, it moves quickly from the gut into the blood, crosses into the brain, and reaches its peak within about an hour.
Here is the part that matters, and the part the word stimulant hides. Blocking the receptor does not remove the adenosine. It keeps arriving and keeps accumulating behind the block, unfelt. When the caffeine finally clears and the receptors open again, all of that stored pressure lands more or less at once. The afternoon lift and the later slump are the same event, read from two ends.
Adenosine is an inhibitory neuromodulator that builds up in the brain across the hours you are awake and pushes it toward sleep. It is the body's homeostatic sleep pressure, a running measure of how long you have been awake, and caffeine produces alertness by blocking the receptors adenosine would otherwise reach.
The dose that lingers
If caffeine cleared the body as fast as it arrives, timing would hardly matter. It does not. In a healthy adult the half-life of caffeine, the time it takes the body to remove half a given dose, runs about 4 to 5 hours, with some sources placing it anywhere from 3 to 6. Half-life compounds the way it sounds: a cup finished in the early afternoon still leaves a meaningful fraction circulating near midnight, long after the felt effect has faded.
The clearance is done mostly by a single liver enzyme, CYP1A2, and it does not simply dispose of the caffeine. More than eighty percent of it is converted into paraxanthine, a metabolite that is itself an active adenosine antagonist with a several-hour half-life of its own. The parent compound leaves, but its work is carried on by a descendant. The practical effect of a cup, in other words, tends to outlast any tidy calculation you might make from the half-life alone.

No two people clear it alike
None of these numbers describe a fixed rule, because the speed at which people process caffeine varies enormously. Clearance can differ by as much as fortyfold from one person to the next, driven partly by inherited variation in that CYP1A2 enzyme. Some people are genuinely fast metabolizers who can drink coffee after dinner and sleep untroubled; others carry a single dose well into the night without ever knowing why.
Other factors shift the same dial. Oral contraceptives can lengthen caffeine's half-life by roughly forty percent, so the same cup lingers longer. Pregnancy slows clearance considerably, while smoking speeds it up. This is one reason a blanket cutoff serves poorly and personal observation serves well, and why anyone weighing caffeine against a medical condition, from a racing heart to persistent insomnia to pregnancy, is better served by a conversation with a physician than by any general figure.
What the timing studies found
When researchers have tested the last cup directly, the results have been consistent and a little sobering. In a 2013 crossover trial, Drake and colleagues gave twelve healthy sleepers 400 mg of caffeine, about two to three cups of coffee, at zero, three, or six hours before bed. Every one of those timings disrupted sleep against a placebo. Even the dose taken a full six hours before bed cut total sleep time by roughly one hour. On that evidence the authors argued for keeping substantial caffeine at least six hours away from bedtime, and noted that the sleepers themselves were largely unaware of the loss.
A 2025 double-blind trial refined the picture by varying dose alongside timing. A modest 100 mg dose, about one cup, could be taken as late as roughly four hours before bed without a significant effect on sleep. A 400 mg dose was another matter: it should not come within about twelve hours of bedtime, and it, not the smaller dose, measurably altered the structure of the night. The lesson is less a single rule than a relationship. The dose and the timing move together, and the reflexive large afternoon coffee is a modern default rather than an aligned choice.

The sleep you don't feel losing
The most striking part of that 2013 study was not the lost hour but the fact that the sleepers did not notice it. Their own accounts of how they slept barely registered the disruption the recordings plainly showed. Caffeine does not always announce itself as a bad night. Often it simply thins the night quietly.
What it thins is mostly the deep end. Caffeine trims slow-wave sleep, the deepest and most restorative stage, and it can stretch the time it takes to fall asleep and add awakenings through the night, while leaving the amount of dream sleep largely intact. The circadian clock feels it too. About 200 mg of caffeine in the early evening has been shown to delay the body's own melatonin rhythm by roughly forty minutes, about half the delay caused by bright light at bedtime. The result is a night that can look ordinary from the outside and still return less than it should.
Living with the last cup
None of this makes caffeine an enemy, and moderate intake is broadly regarded as compatible with good health. General public-health guidance often cites about 400 mg a day as a reasonable ceiling for healthy adults, and the point here is not fear but placement. The same dose is a different thing at eight in the morning than at four in the afternoon.
A few patterns follow gently from the science. Favor caffeine earlier in the day, and give the last substantial dose a wider margin before bed than the old six-hour rule suggests, especially for larger amounts. Notice your own sensitivity, since the range between people is wide. And watch the total daily load, not only the timing, because the two together shape the night. The larger truth is the one that runs under all of it: a habit can feel entirely normal and still be quietly working against the sleep it is meant to protect. This is the kind of pattern we read at the practice, the whole picture of sleep and energy and the daily inputs, alongside a physician, rather than any single cup. Caffeine is a fine companion to a day. It simply asks to be timed.
Common questions
How long does caffeine stay in your system?
Caffeine has a half-life of roughly 4 to 5 hours in a healthy adult, meaning about half of a given dose is still present after that window, with some estimates ranging from 3 to 6 hours. Because it clears at that pace, a cup finished in the early afternoon can still leave a meaningful amount circulating near midnight. More than eighty percent of caffeine is also converted into paraxanthine, an active byproduct that keeps blocking the same receptors, so the overall effect tends to last longer than the half-life alone would suggest.
Why does caffeine keep you awake?
Caffeine keeps you awake by blocking adenosine, a molecule that builds up in the brain over the hours you are awake and pushes it toward sleep. Caffeine fits the same receptors adenosine would use, without activating them, so the brain stops registering the rising signal to rest. The adenosine does not go away while it is blocked; it keeps accumulating, which is why tiredness can return abruptly once the caffeine wears off.
How many hours before bed should I stop drinking coffee?
Research points past the old rule of thumb, especially for larger amounts. In a 2013 trial, 400 mg of caffeine, about two to three cups of coffee, disrupted sleep even when taken six hours before bed, and the authors recommended keeping substantial caffeine at least six hours from bedtime. A 2025 trial found that a smaller 100 mg dose could be taken about four hours before bed without a significant effect, while a 400 mg dose was best kept about twelve hours away. Individual sensitivity varies widely, so anyone with ongoing sleep trouble is best guided by a physician.
Does caffeine affect sleep even if I fall asleep fine?
Yes. In the 2013 study, sleepers were largely unaware of how much their sleep had been disrupted, even though the recordings showed clear effects. Caffeine tends to reduce slow-wave sleep, the deepest and most restorative stage, and it can lengthen the time it takes to fall asleep and add awakenings, while leaving dream sleep mostly intact. A night can feel unremarkable and still return less deep rest than it would have without a late dose.
Why does caffeine affect some people more than others?
The speed at which people clear caffeine can differ by as much as fortyfold, driven partly by inherited variation in the liver enzyme CYP1A2 that breaks it down. Fast metabolizers may drink coffee in the evening and sleep normally, while slow metabolizers carry the same dose well into the night. Oral contraceptives, pregnancy, and smoking also change how quickly caffeine is cleared. Because of this range, a general cutoff matters less than personal observation, and specific concerns are worth raising with a physician.