The link between caffeine and sleep comes down to one number: caffeine's half-life of roughly five to six hours, which means an afternoon coffee can still be acting on your brain at bedtime. Caffeine blocks the signals that build sleepiness through the day, so if your sleep is poor, cutting caffeine after lunch is one of the more reliable things to try.
How does caffeine keep you awake?
Through the day, a substance called adenosine builds up in the brain, and rising adenosine is part of what creates the pressure to sleep, the growing drowsiness you feel by evening. Caffeine works by blocking the receptors that adenosine acts on, so the sleepiness signal is muted even though the adenosine is still there.
This is why caffeine does not give you energy so much as mask tiredness. When it wears off, the accumulated adenosine is still waiting, which is part of why a late coffee can leave you wired but unrested. Sleep pressure is only half of what makes you sleepy at night; the other half is your body clock, described in circadian rhythm basics.
How long does caffeine stay in your system?
The key number is caffeine's half-life: the time for your body to clear half of a dose. For most adults that is around five to six hours, though the full range runs from about two to ten hours depending on the person. So if you have a coffee containing roughly 100mg of caffeine at 4pm, about half is still circulating at 9 or 10pm, and a quarter after that. Even if you feel you have long since stopped noticing it, it can still be interfering with your sleep's depth and structure.
When should you stop drinking coffee?
Controlled studies have tested caffeine taken at different times before bed. The most cited, a 2013 trial by Drake and colleagues, gave people 400mg of caffeine either at bedtime, three hours before, or six hours before. Even the dose taken six hours before bed cut objectively measured sleep by more than an hour. That is the basis for the common advice to avoid caffeine from the early afternoon onwards if you are sensitive to it. There is no single universal cut-off time, but for many people stopping caffeine by early afternoon is a sensible default to test.
It is worth remembering that caffeine is not only in coffee. Roughly speaking, a mug of instant coffee contains about 100mg, filter coffee about 140mg, tea about 75mg, a can of cola about 40mg, and a 250ml energy drink up to 80mg, figures the NHS publishes in its caffeine guidance. Dark chocolate, some painkillers and pre-workout supplements contribute too. When troubleshooting sleep, count all sources, not just the obvious cups; the practical dosing detail is covered in caffeine dose and timing.
On total intake, up to around 400mg a day is generally considered acceptable for most healthy adults, roughly four mugs of instant coffee. The NHS advises pregnant women to keep caffeine below 200mg a day. Staying within those totals matters for general health, but for sleep specifically, when you have your caffeine usually matters more than how much you have overall.
Why does caffeine affect people so differently?
Individual variation in caffeine sensitivity is large and largely genetic. The liver enzyme that breaks caffeine down works faster in some people than others, so a fast metaboliser may drink an espresso after dinner and sleep soundly, while a slow metaboliser is kept awake by a mid-afternoon cup. Age, pregnancy, some medicines and smoking status also change how quickly you clear it.
There is also a vicious circle worth naming. A bad night makes the next-day coffee feel essential, the extra or later caffeine then chips away at the following night, and within a week the habit is propping up a problem it helped create. Breaking the loop usually means accepting a groggier day or two while the timing resets. The most reliable approach is to experiment on yourself: if your sleep is poor, try moving your last caffeine progressively earlier for a week or two and see whether it helps. This fits within the broader habits covered in sleep hygiene evidence, and pairs well with strengthening your body clock through morning light, discussed in daylight and sleep quality.
A practical way to test your own cut-off
Because sensitivity varies so much, a short self-experiment beats any rule of thumb:
- Note your usual last caffeine of the day and how your sleep feels for a week.
- Move the cut-off two hours earlier for the next week, keeping everything else the same.
- Judge the result on how you feel across the whole week, not any single night.
- Watch for withdrawal headaches in the first few days if you also cut your total intake; they pass.
A balanced view
None of this means caffeine is bad. In moderation it is fine for most people and has some benefits, and there is no need to give it up if you sleep well. Systematic reviews of caffeine and sleep consistently find that timing and dose drive the harm, not coffee itself. The point is simply that if your sleep is suffering, caffeine is a common and easily testable culprit, and its long half-life means the timing matters more than people expect. If sleep stays poor after a fair trial of earlier cut-offs, look at the wider picture, and speak to your GP if bad nights persist for a month or more.



