Food, drink & sleepSleep hygiene & daily habits

Caffeine and sleep: how late in the day is too late?

The afternoon coffee feels harmless because you cannot feel it by bedtime. Your sleep can, and the evidence gives a clearer answer to "how late is too late" than most people expect.

A woman resting peacefully in bed in soft morning light, with an empty coffee mug on the bedside table
Dr. Adekunle Ajisebutu, Sleep Physician

Medical reviewer

Dr. Adekunle Ajisebutu, MD

Sleep Physician · Board-certified in Sleep Medicine

Pending medical review

In short

Caffeine takes about five hours to fall by half, so a 3 pm coffee is still active at bedtime. In the best-known study, 400 mg six hours before bed cut sleep by about an hour, and people underestimated the loss. For most adults, stop caffeine eight hours before bed, count tea, cola, energy drinks and headache tablets, and run a two-week self-test to find your own cut-off.

Key takeaways

  • Caffeine blocks adenosine, the brain's sleep-pressure signal, and its half-life is about five hours, so half of a 3 pm coffee is still in your system at 8 pm.
  • In a 2013 Journal of Clinical Sleep Medicine study, 400 mg of caffeine taken six hours before bed cut measured sleep by about an hour, and participants underestimated the loss.
  • Clearance speed varies widely: genetics, smoking, pregnancy, age, liver disease and some medicines all change how long caffeine lasts, so no single cut-off fits everyone.
  • Tea, cola, energy drinks, dark chocolate and some headache tablets carry meaningful caffeine, decaf is low but not zero, and energy drinks and caffeine tablets are not for children or teens.
  • Start with an eight-hour cut-off, shift timing rather than cutting the total to avoid withdrawal headaches, and confirm it with a two-week self-test.

Why an afternoon coffee still matters at bedtime

Caffeine blocks adenosine, a chemical that builds up in the brain across the day and creates sleep pressure. The pressure keeps building; you just feel less of it, and when the caffeine clears, the backlog is waiting.

The problem is how slowly it clears. Caffeine's half-life, the time your body takes to remove half of a dose, is about five hours in a typical adult, so a 200 mg coffee at 3 pm leaves roughly 100 mg circulating at 8 pm and 50 mg at 1 am: too little to feel, but often enough to make sleep lighter and shorter.

What the six-hour study found

The most cited timing experiment, by Drake and colleagues in the Journal of Clinical Sleep Medicine in 2013, gave twelve healthy adults 400 mg of caffeine (roughly two to three strong coffees) or a placebo at bedtime, three hours or six hours before bed, with home sleep monitoring.

Even the six-hour dose cut measured sleep by about an hour, and participants underestimated the loss. The authors advised avoiding substantial caffeine for at least six hours before bed: for an 11 pm bedtime, nothing sizeable after 5 pm. Six hours is a floor, not a promise; the study used one large dose in healthy adults, and slow metabolizers will need more.

Why your cut-off is not your friend's cut-off

Caffeine is broken down mainly by a liver enzyme called CYP1A2, whose speed varies widely between people. Some of the difference is inherited (genetically "fast" versus "slow" metabolizers); some is circumstance:

  • Smoking speeds the enzyme up, shortening caffeine's half-life by as much as half, so quitting can make a usual coffee hit harder.
  • Pregnancy slows clearance dramatically; the half-life can reach 15 hours in the final trimester.
  • Some medicines and liver disease slow the enzyme, so caffeine lingers.
  • Age: older adults tend to process caffeine more slowly and feel its effect on sleep more strongly.

People also differ in how strongly they respond to the same dose, partly because the adenosine receptors caffeine acts on vary genetically too, which is why two colleagues can share a 4 pm coffee and only one lies awake.

Hidden caffeine you may not be counting

Most people count their coffees and forget the rest. Approximate amounts, using the American Academy of Sleep Medicine's estimates:

  • Brewed coffee, 8 oz (240 ml): about 95 mg. One espresso shot: around 64 mg. Coffee-shop servings vary enormously: the same 16 oz coffee bought on six days ranged from 259 to 564 mg.
  • Black or green tea, one cup: roughly 45 to 55 mg.
  • Cola, 12 oz can: about 35 to 55 mg, diet versions included.
  • Energy drinks: about 77 mg in a small 8.4 oz can and 150 to 175 mg in a 16 oz can.
  • Chocolate: a milk chocolate bar has under 10 mg, but dark and baking chocolate carry more.
  • Medicines: two Extra Strength Excedrin (a caffeine and painkiller combination) contain 130 mg; alertness tablets, 200 mg each.
  • Decaf is not zero: brewed decaf has roughly 2 mg a cup, though products vary.

These figures and the limits below are for adults. The AASM advises parents to limit children's caffeine; energy drinks and caffeine tablets are not appropriate for children or teenagers and, as the FDA cautions, are no substitute for sleep.

Caffeine, insomnia and sleep apnea

Caffeine can cause insomnia on its own; researchers have even used it to model insomnia. It is seldom the whole story in chronic insomnia, but it is a recognized, reversible cause of poor sleep that feeds the cycle: a bad night leads to more caffeine, later in the day, and a lighter, shorter night follows. Our guide to insomnia and what actually helps covers the rest of the picture.

Caffeine can also mask the daytime sleepiness that would otherwise prompt someone to get checked for sleep apnea. If you need several coffees to stay awake despite a full night in bed, especially if you snore or wake unrefreshed, read about the symptoms and risks of sleep apnea or try the STOP-Bang self-check.

A realistic cut-off, and a two-week self-test

A sensible default for most adults is no caffeine within eight hours of bedtime, and none within ten if you are a slow metabolizer, older, or dealing with insomnia: in practice, last coffee by early afternoon. Keep daily totals under about 300 to 400 mg, the AASM's suggested ceiling.

Rather than trusting a rule, test it:

  1. Week one: change nothing, just record. Log every caffeine source with its time and rough amount, plus your bedtime, time to fall asleep, night wakings, and how you felt on waking.
  2. Week two: move your cut-off earlier, to eight hours before bed (or noon, for a clearer test). Keep the total the same and your bedtime steady.
  3. Compare the two weeks. If week two is clearly better, you have your answer. If nothing changed, caffeine timing is probably not your main problem.

Shifting timing rather than cutting the total avoids most withdrawal. If you do cut back, go gradually: stopping abruptly commonly brings headache, tiredness and low mood starting 12 to 24 hours after the last dose, peaking over the next day or two and lasting up to a week; dropping about one serving every few days usually avoids that.

When to talk with a doctor

Chest pain or discomfort, fainting, or a racing or irregular heartbeat that does not settle within minutes needs urgent medical help: call your local emergency number, whatever you think triggered it.

Talk with a doctor if caffeine regularly gives you milder palpitations; if you have high blood pressure or a heart condition; if you are pregnant or breastfeeding (obstetric guidance caps pregnancy intake at 200 mg a day, and the AASM suggests less); or if you take medicines that may interact with it. If sleep stays poor once caffeine is well away from bedtime, mention that too; caffeine may have been hiding the real cause.

In summary

Caffeine blocks the brain's sleep-pressure signal and takes about five hours to fall by half, so an afternoon dose is still active at bedtime. In the best-known study, 400 mg six hours before bed cut sleep by roughly an hour, and people underestimated the loss. Your cut-off depends on genetics, age and circumstances, so count every source, start from eight hours before bed, and run a two-week self-test to find what your body actually needs.

Questions people ask

How many hours before bed should I stop drinking coffee?

At least six hours for a sizeable dose, based on a 2013 study in which 400 mg taken six hours before bed cut sleep by about an hour. Eight hours is a safer default for most adults, and ten or more if you are older, a slow metabolizer, or already struggling with insomnia.

Does decaf coffee affect sleep?

Brewed decaf contains only a few milligrams of caffeine per cup, which is negligible for most people. If you are very sensitive, keep in mind that amounts vary between products and coffee shops.

Why does caffeine keep some people awake but not others?

Caffeine is cleared by a liver enzyme (CYP1A2) whose speed is partly inherited and also changed by smoking, pregnancy, age, liver disease and some medicines. People also differ in how strongly they respond to a given dose, partly through genetic variation in the adenosine receptors caffeine acts on.

Will I get headaches if I cut back on caffeine?

Stopping abruptly often causes headache, tiredness and low mood starting 12 to 24 hours after the last dose and lasting up to a week. Moving your caffeine earlier instead of cutting the total, or reducing by about one serving every few days, usually avoids this.

Two-minute check

Wondering about snoring or daytime sleepiness? STOP-Bang is scored in your browser.

Take the self-check

Keep reading