Sleep · 8 min read

Caffeine and sleep: how long before bed to stop, and why it lingers

Sources checked Not yet reviewed by a clinician How we review

How this was made: drafted with AI (Claude); we check every number and link against its source. Review by a clinician is planned and has not started yet. When a reviewer signs a page, their name appears above. How we review

TL;DR. Caffeine can still affect your sleep many hours after your last cup. A 2023 review of 24 studies found that caffeine cut night sleep by about 45 minutes on average and made deep sleep a little shorter. The same review suggests having a regular coffee at least about 9 hours before bed. People differ a lot, so the best cut-off is the one you find by testing it: move caffeine earlier for two weeks and see what changes.

Contents
  1. Does caffeine affect sleep? The short answer
  2. How long does caffeine last in your body?
  3. How long before bed should you stop drinking caffeine?
  4. Caffeine can push your body clock later
  5. The tired–coffee–tired loop
  6. Hidden sources of caffeine
  7. How much caffeine is too much?
  8. How to cut back on caffeine without the crash
  9. When to seek help
  10. FAQ

Coffee is often how people get through a short night. The catch is that it can make the next night shorter too, and that loop is easy to miss.

Does caffeine affect sleep? The short answer

Yes, for most people, and often more than they notice. Caffeine works by blocking adenosine, a chemical that builds up while you are awake and makes you feel sleepy. Block it in the evening and your body gets a weaker "time to sleep" signal at bedtime.

A systematic review and meta-analysis pooled 24 studies of caffeine and night sleep. On average, caffeine (Gardiner et al. 2023):

  • cut total sleep time by about 45 minutes;
  • lowered sleep efficiency (the share of time in bed spent asleep) by about 7%;
  • added about 9 minutes to the time it took to fall asleep and about 12 minutes of time awake during the night;
  • shifted sleep a little from deep sleep towards lighter sleep.

Experts have also warned that the effect of regular caffeine on sleep and daytime sleepiness is widely underestimated, by the public and doctors alike (Roehrs & Roth 2008).

How long does caffeine last in your body?

The effects usually start about 30 minutes after a drink and can last five hours or longer (Sleep Foundation). Its half-life, the time the body takes to clear half of it, ranges widely, from about 2 to 12 hours (Sleep Foundation). So with a longer half-life, a good share of a mid-afternoon coffee can still be in your system at midnight.

Why the range is so wide: how fast you clear caffeine depends on your genes, age, hormones, smoking, liver health, diet and some medicines (Nehlig 2018). That is why one person can drink an espresso after dinner and sleep fine while another lies awake after a cup at 3 p.m.

How long before bed should you stop drinking caffeine?

There is no single cut-off that suits everyone, but the research points to longer gaps than most people expect.

  • The 6-hour study. Adults took a large dose of caffeine (400 mg) at bedtime, 3 hours before or 6 hours before. All three disturbed sleep compared with a placebo, including the dose taken 6 hours before bed (Drake et al. 2013). The authors concluded that substantial caffeine should be avoided for at least 6 hours before bedtime.
  • The meta-analysis. To avoid losing sleep time, the review estimated that a standard cup of coffee (about 107 mg) should be finished at least 8.8 hours before bed, and a typical pre-workout supplement at least 13.2 hours before (Gardiner et al. 2023).
  • The common guideline. A frequently given rule is to stop caffeine at least eight hours before bed: for a 10 p.m. bedtime, that means nothing after about 2 p.m. (Sleep Foundation).

A practical starting point: if you go to bed around 11 p.m., keep caffeine to the morning and stop by early afternoon. If you are sensitive or sleep badly, try an earlier cut-off still.

Caffeine can push your body clock later

Caffeine does not only keep you awake on the night itself. In a carefully controlled lab study, a caffeine dose similar to a double espresso taken 3 hours before bedtime delayed the evening rise of melatonin, the hormone that signals night to the body, by about 40 minutes (Burke et al. 2015). That was nearly half the effect of three hours of bright evening light.

It was a small study, but it fits a common pattern: late coffee, later sleepiness, a later bedtime and a harder morning. If your sleep times have been drifting later, see how to shift your sleep schedule, which also covers caffeine timing.

The tired–coffee–tired loop

Here is the loop many people get stuck in: a short night, more coffee to get through the day, a later or lighter night's sleep, and more coffee the next day. Regular caffeine use is linked with disturbed sleep and daytime sleepiness, and some of the "boost" in regular users may be mostly bringing them back to normal after an overnight break, rather than making them sharper than usual (Roehrs & Roth 2008). If you also need long naps to get through the day, see how long a nap should be; a short early-afternoon nap is often a better tool than a late coffee. If you are tired all the time whatever you drink, see why am I always tired? for the other common causes and when to see a doctor.

Hidden sources of caffeine

Coffee is the obvious one, but caffeine is also in:

  • tea, including black and green tea;
  • cola and many other soft drinks;
  • energy drinks and pre-workout products, some with high doses;
  • chocolate and cocoa, in smaller amounts;
  • some painkillers and cold remedies (Sleep Foundation).

Decaf still contains a little caffeine. Highly concentrated or pure caffeine products can be dangerous, and medical experts advise against energy drinks for children and teens (FDA).

How much caffeine is too much?

For most healthy adults, the FDA cites 400 mg a day as an amount not generally linked with harmful effects, while noting wide differences in how sensitive people are (FDA). That is a general safety figure, not a sleep target: even well under it, caffeine late in the day can still cost you sleep. Some health conditions, pregnancy and some medicines change what is right for you, so please read the "who should be careful" notes on this page and ask a doctor if any apply.

How to cut back on caffeine without the crash

If you decide to move caffeine earlier or have less, go gradually. Stopping suddenly can bring withdrawal symptoms, most often headache, tiredness, low mood, irritability and trouble concentrating. These usually start 12 to 24 hours after the last dose and can last from 2 to 9 days; even stopping as little as 100 mg a day caused symptoms in some studies (Juliano & Griffiths 2004). The FDA also advises reducing gradually; withdrawal is not considered dangerous, but it can be unpleasant (FDA).

A simple two-week test:

  1. Pick a cut-off time, for example about 9 hours before your usual bedtime (longer for strong drinks), or use the caffeine cutoff calculator.
  2. Move the latest cup earlier by an hour or so every few days until you reach it, rather than all at once.
  3. Swap rather than skip: decaf, herbal tea or water at the time you used to have the late one.
  4. Keep your wake time steady, so you can see the effect of caffeine and not of a shifting schedule.
  5. Write it down. A sleep diary with a note on caffeine makes the pattern easier to spot than memory does.

Caffeine timing is one part of sleep hygiene. Like the other habits, it is worth getting right, but on its own it rarely ends a long-running sleep problem. If you still lie awake once late caffeine is gone, see what to do when you can't sleep.

When to seek help

Please talk to a doctor if:

  • you have trouble falling or staying asleep on most nights for months, even after cutting late caffeine;
  • you feel very sleepy in the day, or you rely on more and more caffeine to function;
  • caffeine gives you palpitations, chest pain or strong anxiety;
  • you snore loudly, gasp or stop breathing in your sleep;
  • you feel low most days, or thoughts of harming yourself appear.

If you are in danger or thinking about harming yourself, contact emergency services or a crisis line now. These lines are free and confidential:

Free, confidential crisis lines by country are listed in the box below. See the crisis lines ↓

More options are on our Get help page.

FAQ

How long before bed should I stop drinking coffee?

A common guide is at least eight hours. A 2023 review estimated that a standard cup of coffee should be finished at least 8.8 hours before bed to avoid losing sleep time. Sensitive people may need longer.

Can I drink coffee and still fall asleep fine?

Some people can, but falling asleep is not the whole story. Caffeine can make sleep shorter and lighter even when you drop off without trouble.

How long does caffeine stay in your system?

Its half-life ranges from about 2 to 12 hours, depending on genes, age, hormones, smoking, medicines and more. Effects can last five hours or longer.

Does decaf affect sleep?

Decaf has much less caffeine but not none. For most people it is a reasonable swap for an afternoon cup.

Will cutting caffeine make me more tired at first?

Possibly, for a few days. Withdrawal can bring headache and tiredness, which is why cutting back gradually is usually easier.

Sources

  1. Gardiner C, Weakley J, Burke LM et al. The effect of caffeine on subsequent sleep: a systematic review and meta-analysis. Sleep Med Rev 2023
  2. Drake C, Roehrs T, Shambroom J, Roth T. Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed. J Clin Sleep Med 2013
  3. Burke TM, Markwald RR, McHill AW et al. Effects of caffeine on the human circadian clock in vivo and in vitro. Sci Transl Med 2015
  4. Roehrs T, Roth T. Caffeine: sleep and daytime sleepiness. Sleep Med Rev 2008
  5. Nehlig A. Interindividual differences in caffeine metabolism and factors driving caffeine consumption. Pharmacol Rev 2018
  6. Juliano LM, Griffiths RR. A critical review of caffeine withdrawal. Psychopharmacology 2004
  7. U.S. Food and Drug Administration. Spilling the beans: how much caffeine is too much?
  8. Sleep Foundation. Caffeine and sleep

Read next

Resteady programmes — join the waitlist

We are building short daily skills programmes: 14 days of Calm under pressure and 28 days for sleep. Join and we will write when the beta opens. Review of the programmes by clinicians is planned and has not started yet.

Join the waitlist

If things are hard right now

Resteady is not an emergency service. If you are in danger or thinking about harming yourself, call a crisis line or emergency services now. It is free and confidential.

Numbers can change. If a line does not answer, call 112 or your local emergency number.

Open SOSAll lines by country

  • EU / EEA112Emergency number
  • Ukraine112Emergency number
  • Ukraine103Ambulance
  • Ukraine0 800 210 160People in Need psychological support (24/7, free)
  • United States988Suicide & Crisis Lifeline
  • United States988988 Lifeline in Spanish (press 2, or text AYUDA to 988)
  • Colombia123Emergency number
  • Colombia106Línea 106 mental health support (24/7, free)
  • Chile*4141Línea *4141 suicide prevention (24/7, free, from mobile phones)
  • Peru113Línea 113, option 5: mental health support (24/7, free)
  • Mexico800 911 2000Línea de la Vida mental health and addictions support (24/7, free)
  • Argentina911Emergency number
  • Argentina135Centro de Asistencia al Suicida (free from Buenos Aires City and Greater Buenos Aires, 8:00–24:00)
  • Argentina0800 345 1435Centro de Asistencia al Suicida (nationwide, 8:00–24:00)
  • United Kingdom116 123Samaritans
  • Ireland116 123Samaritans
  • Germany0800 111 0 111TelefonSeelsorge
  • Spain024Línea 024
  • Poland116 123Telefon zaufania dla osób dorosłych w kryzysie
  • France3114Numéro national de prévention du suicide

Other countries: findahelpline.com — Free, confidential lines for every country.