Whenever I sit down to program, I quickly become sleepy and mentally drained, almost as if my brain shuts down as soon as I begin coding. I may feel fairly alert beforehand, but the tiredness appears soon after starting. This did not used to happen—I could once program for hours without a problem. Has anyone experienced a similar change, and what helped?
4 Answers
Try observing when the sleepiness starts. Is it after reading difficult material, debugging, sitting in a certain room, or working at a particular time of day? Short timed sessions, standing up between sessions, and making the first task very easy can help identify whether the cause is mental overload, environment, or a broader energy problem.
It could also be boredom, overwhelm, or burnout—especially if the sleepiness appears with tasks that feel difficult or uninteresting but disappears when you switch to videos or other stimulating activities. Try breaking coding into very small, concrete tasks and changing your routine or workspace. If programming used to feel enjoyable and this change has lasted, taking a short guilt-free break may help you figure out whether burnout is involved.
Sometimes this happens when your brain has gotten used to constant, highly stimulating activities. Programming requires sustained attention, so it can feel unusually exhausting when you return to it. Start with short sessions, take regular breaks, and gradually build your focus back up instead of forcing yourself through hours of work. It may take a few weeks for the activity to feel comfortable again.
First check the basics: consistent sleep, regular meals, hydration, daylight, and some physical activity. Poor sleep or a sedentary routine can make demanding mental work feel much harder. If those areas are in good shape and this sudden fatigue keeps happening, it would be sensible to talk with a doctor, particularly if you also feel unusually tired at other times or notice additional symptoms.
Even eating reasonably well does not rule out every health issue, since sleep problems and medical conditions can affect energy and concentration. Persistent or worsening fatigue is worth getting checked rather than assuming it is just motivation.

A gradual reset from constantly switching between short, stimulating content may help too. The key is probably rebuilding your attention span rather than trying to power through the sleepiness.