The reason you cannot sleep may be an evening coffee. How long caffeine actually stays in your body.
Caffeine does not restore energy. It occupies the place where the sleepiness signal would normally land, so you stop noticing the signal. The signal itself keeps building up and returns all at once as the caffeine clears.