A team of researchers in Scotland looked at how late in the day you can drink coffee, without it keeping you up all night!
They suggest that you should stop drinking stuff with caffeine SIX HOURS before bed. After that, it can mess with your internal clock.
The study also found that drinking four to five cups a day is totally fine as long as you stop early enough. But some people metabolize caffeine more slowly, so keep that in mind.
In other coffee news: A big study in the U.K. just found that drinking three to four cups a day can lower your risk for liver cancer.
It tracked a half-million people for more than a decade. And coffee drinkers were 49% less likely to die of chronic liver disease.