You don’t have to drink coffee within minutes of going to bed for this to occur to feel its lasting effects. Caffeine can stay in your system for hours at a time and can affect your sleep long after its stimulating effects wear off (viaWell+Good). Exactly how long it stays in your system depends on the speed at which you metabolize caffeine.
For instance, if you’re a fast caffeine metabolizer, you may be able to continue drinking coffee later on in the day than those who metabolize caffeine at a slower rate. According to Dr. Dan Reardon, who has studied coffee’s effects, you should stop drinking coffee anywhere from 12 p.m. to 2 p.m. if it typically takes you longer to metabolize caffeine.
If you metabolize caffeine at a faster rate, however, your cutoff time can be closer to 5 p.m. “Let’s not forget that even for a fast metabolizer of caffeine, there could still be a cumulative effect of drinking lots of coffee early in the day, which could slow down the rate at which they break down their caffeine later,” Dr. Reardon told Well+Good. In that case, it’s a good rule of thumb to stop drinking coffee around lunchtime.