Key takeaways:
The caffeine in coffee affects your levels of adenosine and melatonin, two key players in making you sleepy.
Because of this, drinking coffee late at night likely isn’t a good idea. In fact, it may be beneficial to try to avoid consuming caffeine within 6 hours of bedtime.
Warm milk or tea is a better choice for a pre-sleep beverage.
If you’ve ever drank coffee late at night, you may have found yourself tossing and turning as the hours ticked by. The caffeine in coffee can affect some of the chemical compounds in your body — namely, adenosine and melatonin — that make you sleepy. And this can interfere with your nightly rest.
This doesn’t necessarily mean that you have to cut out coffee completely. You should just be strategic about what time of the day you drink it.
How does caffeine affect sleep?
Throughout your day, your body uses a molecule called adenosine triphosphate (ATP) for energy. As each ATP molecule is used by a cell, it’s broken down into smaller molecules that then get recycled in different ways.
“What's left is adenosine, which builds up and makes you sleepy,” said Raj Dasgupta, MD, an assistant professor of clinical medicine at the University of Southern California Keck School of Medicine in Los Angeles. “And how does caffeine work? It inhibits adenosine.”
So caffeine blocks adenosine’s sleepy effects.
Research has also shown that caffeine may decrease melatonin production, especially when consumed too close to bedtime. This effect theoretically delays the onset of sleepiness by disrupting your circadian rhythm, your body’s internal clock. Your circadian rhythm is controlled by external factors, like sunlight and darkness. And it’s controlled as well by internal factors, like melatonin and adenosine levels. By interfering with internal factors, caffeine may make it harder for you to fall and stay asleep.
Can caffeine cause insomnia?
While it’s just one of many potential causes, consuming caffeine may lead to insomnia symptoms, according to research. In particular, caffeine seems to have the biggest effect on staying asleep, making it more likely that you’ll wake up in the middle of the night. However, the science isn’t totally conclusive here, and the effects likely depend on the individual.
One review looked at whether totally avoiding coffee could affect sleep quality. The researchers found a link between avoiding coffee and better sleep quality and longer sleep duration. And, on days that people switched from caffeinated to decaf coffee, it wasn’t as hard for them to fall asleep.
Should I avoid having coffee at night?
If you’re having trouble sleeping, it’s worth avoiding caffeinated coffee at night. However, sleep is different for every individual. And some people are more sensitive to caffeine than others. So it’s important to find what works for you.
Not sleeping well? Learn more about the most common reasons people can’t sleep and what you can do about each one.
Thinking of switching to decaf coffee? Learn more about whether decaf coffee is good or bad for you and how it stacks up to regular coffee.
What happens if you don’t get enough sleep? Not getting a good night’s rest can have short- and long-term impacts on your health.
While the guidelines are mixed, some studies suggest it’s beneficial to avoid caffeine starting around 6 hours before going to bed. But Dr. Dasgupta didn’t want to overcommit to a specific number of hours.
“I suggest avoiding it within 4 hours before going to bed,” he said. “And of course, if you're very sensitive, don't have caffeine after lunch.”
Best time to drink coffee
While there’s some research on when you shouldn’t drink coffee, there’s not a lot of research on when you should.
Read more like this
Explore these related articles, suggested for readers like you.
One large study showed that drinking coffee was linked with lower mortality rates — but only in those who drank coffee in the morning. Coffee didn’t impact mortality in people who drank it throughout the day.
It’s also possible that drinking coffee in the morning may be best for athletic performance. In one small study, researchers found that when athletes drank coffee in the morning, it improved their:
Performance
Reaction time
Energy and enthusiasm (“vigor”)
But the best time for you to drink coffee likely depends on:
How you react to caffeine
How much coffee you drink
What your schedule is like
What you’re hoping to gain from drinking coffee
If you’re looking for energy to tackle your day, drinking coffee in the morning might be your best bet. If you want to beat a midafternoon slump, after lunch may be most beneficial. If you’re using caffeine as an exercise enhancer, you may need to time your coffees to your workouts.
How long does coffee stay in your system?
The average half-life of caffeine is about 4 to 6 hours. This is the amount of time needed for the body to break down half the original amount of caffeine. But this can range anywhere from 1.5 to 9.5 hours, depending on your individual biochemistry. It can also depend on other factors that affect the speed at which you metabolize caffeine. These factors include:
Nicotine products can speed up caffeine metabolism by as much as 50%.
Pregnancy or nursing slow down the metabolizing of caffeine.
Food, like broccoli, might speed up caffeine metabolism, although more research on this topic is needed.
Genetics can help some people naturally metabolize caffeine faster than others.
Oral contraceptives slow down the metabolizing of caffeine. So taking this type of birth control can mean that it takes longer for caffeine to leave your system.
What drinks are high in caffeine?
If you’re trying to improve your sleep, it helps to know what drinks are high in caffeine. Here are four types of drinks to be wary of, plus how much caffeine they contain:
Brewed coffee: An 8 oz cup of coffee typically contains 95 mg to 165 mg of caffeine, depending on brewing time. And certain decaf coffees can have around 12 mg of caffeine per 8 oz serving.
Soda: A 12 oz soda typically contains around 34 mg of caffeine.
Tea: An 8 oz cup of green tea typically contains 25 mg to 29 mg of caffeine, while the same amount of black tea contains 25 mg to 48 mg.
Energy drinks: A 16 oz energy drink contains anywhere from 70 mg to 200 mg of caffeine (and possibly even more).
So, what should I drink before bed?
It’s often said that a cup of warm milk will put you right to sleep. But is that true? And what about herbal tea?
Here’s what we know about the best drinks to sip before bed:
Warm milk: It’s possible that the tryptophan in milk helps with better sleep. In a small study of people in a hospital, participants who drank warm milk and honey twice a day reported improved sleep.
Chamomile tea: Chamomile tea is a popular bedtime beverage. Although the evidence is lacking overall, researchers do believe the drink has some sleep benefits. At the very least, it doesn’t have the stimulant effect of coffee.
Tart cherry juice: Tart cherries contain melatonin and other anti-inflammatory substances. Some studies, though small, have shown it helps with sleep.
Banana smoothie: Eating bananas might also increase melatonin levels. The research isn’t conclusive. But a banana smoothie may be something worth trying if you’re looking for a coffee or dessert substitute.
If you’re lactose intolerant or sensitive to dairy, Dr. Dasgupta recommends trying almond milk. “I think it addresses those with lactose intolerance, and almond milk contains a lot of tryptophan and magnesium,” he said.
Of course, you don’t have to drink anything at all. Some research suggests that cutting off food and drinks at least 1 hour before bed can decrease the number of times you wake up in the middle of the night.
Are there any benefits of drinking coffee at night?
There’s probably no benefit to drinking coffee at night specifically. But coffee consumption in general has been associated with several health benefits. For example, it has been associated with a lower risk of:
Alzheimer’s and Parkinson’s diseases
Heart disease and death from heart-related problems
Depression
There are certain situations where you may feel like you need to drink coffee at night. For example, if you work night shifts, you may be looking for a way to offset fatigue.
The bottom line
For many people, drinking coffee late at night can prevent a good night’s rest. But there’s no standard recommendation about what time you should stop drinking coffee for better sleep. Some research suggests that you should stop around 6 hours before bedtime. But the ideal gap between your last cup and getting in bed may be bigger or smaller, depending on your body and individual needs.
Why trust our experts?


References
Burke, T. M., et al. (2015). Effects of caffeine on the human circadian clock in vivo and in vitro. Science Translational Medicine.
Chaudhary, N. S., et al. (2016). Caffeine consumption, insomnia, and sleep duration: Results from a nationally representative sample. Nutrition.
Drake, C., et al. (2013). Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed. Journal of Clinical Sleep Medicine.
Fakhr-Movahedi, A., et al. (2018). Effect of milk-honey mixture on the sleep quality of coronary patients: A clinical trial study. Clinical Nutrition ESPEN.
Grzegorzewski, J., et al. (2022). Pharmacokinetics of caffeine: A systematic analysis of reported data for application in metabolic phenotyping and liver function testing. Frontiers in Pharmacology.
Hakooz, N., et al. (2007). Effects of dietary broccoli on human in vivo caffeine metabolism: A pilot study on a group of Jordanian volunteers. Current Drug Metabolism.
Iao, S. I., et al. (2021). Associations between bedtime eating or drinking, sleep duration and wake after sleep onset: Findings from the American time use survey. British Journal of Nutrition.
Institute of Medicine (US) Committee on Military Nutrition Research. Pharmacology of caffeine. Caffeine for the Sustainment of Mental Task Performance: Formulations for Military Operations. National Academies Press.
O’Callaghan, F., et al. (2018). Effects of caffeine on sleep quality and daytime functioning. Risk Management and Healthcare Policy.
Raj Dasgupta. (n.d.). About Raj Dasgupta.
Sae-Teaw, M., et al. (2013). Serum melatonin levels and antioxidant capacities after consumption of pineapple, orange, or banana by healthy male volunteers. Journal of Pineal Research.
Scharf, M. T., et al. (2008). The energy hypothesis of sleep revisited. Progress in Neurobiology.
Shilo, L., et al. (2002). The effects of coffee consumption on sleep and melatonin secretion. Sleep Medicine.
Sin, C. W. M., et al. (2009). Systematic review on the effectiveness of caffeine abstinence on the quality of sleep. Journal of Clinical Nursing.
Souissi, M., et al. (2012). Effects of morning caffeine’ ingestion on mood states, simple reaction time, and short-term maximal performance on elite judoists. Asian Journal of Sports Medicine.
Temple, J. L., et al. (2017). The safety of ingested caffeine: A comprehensive review. Frontiers in Psychiatry.
U.S. Food and Drug Administration. (2024). Spilling the beans: How much caffeine is too much?
Wang, X., et al. (2025). Coffee drinking timing and mortality in US adults. European Heart Journal.
Yang, A., et al. (2010). Genetics of caffeine consumption and responses to caffeine. Psychopharmacology.
Yurcheshen, M., et al. (2015). Updates on nutraceutical sleep therapeutics and investigational research. Evidence-Based Complementary and Alternative Medicine.










