Does programming give you a headache? Do you feel tired after few hours of coding? If so this article is for you. You will find most common reasons for programming migraine and how to relieve the pain.

Step 1: Identify the reason for the headache

The first step is to find what is the reason for the headache. It's extremely important to identify what is the cause and what is the type of the headache. This will help you to treat it better and address the problem in right direction. Below you can find most popular reasons associated with programming headache:

  • Eye strain
  • Bad colors / Dark theme(+ astigmatism)
  • Bad posture
  • Bad music / Noise
  • Over-thinking
  • Dehydration

Once the type of headache(you are suffering from) and the reason are clear you will know what practice to use to relieve it. In some cases, a head massage can help in others taking longer breaks. In the next step you can find how to ease the pain caused by headaches.

Step 2: Tips to relieve coding migraine

What are the best methods to relieve stress? I'll try to list the one which works for me.

Try Massage

You can do it yourself, or simply ask a friend / a specialist.** A few minutes massaging your neck, top of the head and temples can ease a tension headache, which may result from stress**. You can also buy simple massager like:

I'm using the first one and it really make the huge difference in the end of the long working day. After several minutes of massage I feel warming feeling which:

I can feel that all the way down in my toes!

Deal with Bad music / Noise

I was working simultaneously in open office and from home for several years (on weekly basis). I found out that my performance from the office was bad and I was less productive. It was really hard for me to concentrate and focus on the task which I had for the day. At the end of the working day I had also - subtle pain in my forehead.

I tried to change different things until I found the real cause for my suffers - the noise in the open space. The noise was on from the early morning till the late evening. Only when most workers were gone and the air-conditioner was off I was able to do something properly. What was the solution which helped me to deal with the constant noise? It's called - Noise Canceling Headphones.

Below you can find two models which will do the job:

Be careful because bad music might be another reason for programming migraine. So I prefer to:

  • Work on quite place in nature when it's possible
  • If not - use noise canceling headphones with nature sounds
  • Listen low acoustic music


Dehydration is one of the greatest migraine triggers. It might be related to drinking alcohol, too many cups of coffee, too salty food or simply don't drinking water. The focus on hard problems or staying too long in front of computer might deceive your thirsty feeling.

What could be done? You can

  • add a cup or bottle of water on your desk. If the cup is present on your desk it's more likely to drink it.
  • Frequent breaks will normalize your senses - so you will find if you are thirsty or not.
  • Drinking tea

Fix bad posture problem

Incorrect posture causes migraine and back pain. Most probably there is muscle imbalance which can be treated in long term with sport, stretching and exercises. In short term (or if you don't have 15 minutes per day for stretching) you can try to:

Keep in mind that the long term goal is to stay less on the chair and be healthy. Even the most ergonomic chair will not help if you have bad habits. The key point here is to cure the muscle imbalance.

Bad colors / Dark theme(+ astigmatism)

There are studies that show some fonts and colors can result in migraine headache. Monitor screen colors, color theme, dark mode can be considered as triggers. For example dark mode theme in combination with astigmatism result in eye strain for me.

Best option here is to experiment with different setups and applications. Most probably your monitor have native option for regulating the working regime like - I-Style color:

  • Standard
  • Game
  • Cinema
  • Scenery
  • Text

I found out the Text regime is best working for me. In combination with programs like Red-Shift which decrease the levels of the blue light - I solved the headache related to colors and intense light.

Decrease eye strain

Another common problem is eye strain. It can be related to many factors like:

  • wrong view angle
  • staying for too long of monitor
  • bad or no light
  • bad / old monitor

You can try to change the position of your desk - closer or further from a window. To decrease direct sunlight or change the direction of your monitor. Play with the level and the inclination of the monitor.

Change of fonts and resolution is another option. If you read text in your browser you can increase the font size. A simple trick which helped me a lot in the past is to rinse my eyes with cold water. I did this regularly for one month and the headache which I had at that time due to bad monitor - disappear completely.

Buying a new monitor still can be an option. You can find some ideas below:


Don't try so hard. Take difficult problems easy and step by step. Take your mind off the problem, switch to something else, just relax or simply enjoy the day outside. Do take an afternoon nap to rest your brain, eyes and nerve system.

Attack the problem from different angle or ask for help. Think deeply for simple things requires a lot of energy and mental strain. Try to balance it with the same amount of relaxation.

Step 3: Tips for prevention of coding migraine

In addition to previous steps you can find several simple things which you can do to ease the pain. Try these tips and get to feeling better:


Meditation play huge role in the connection between our internal and external worlds. It helps to controls anxiety, promotes emotional health, fight stress and enhance focus. Start short meditation sessions on daily basis and you will find a clear picture of your mind. By improving attention and concentration you will solve problems faster with less mental power.

Frequent walks

The benefits of nature walks are difficult to be listed in a short article like this. But definitively one of them is - headache and stress prevention. The more time you spent out in the nature the more you will benefit from reduction in stress levels and burn out probability.

For sure nature walks improve concentration which will help you solve hard problems much faster and with less efforts. Fresh air is the natural food for your brain. Quick walk during the work day may do the difference between successful worker and struggler.

Pro Tip: You can remove your glasses when you walk in the nature or outside. This helps me to relax my eyes and mind (I have average near-sightedness). But please be careful!

Afternoon naps and more sleep

Do you know what is common between:

  • Aristotle
  • Leonardo Da Vinci
  • Albert Einstein
  • Thomas Edison

At least one thing which I know was their love for naps. Working as a programmer is mental draining occupation which requires long periods of concentration. One of the ways to rest from this long periods is by sleeping and switching off your brain for some time.

Sleep is extremely important for memory, concentration and relax of the mind. 8 hours of strong sleep is a good recipe for headache killer.


People who suffer from programming headache are susceptible to a number of factors that can trigger and boost such condition. Programing is related to staring at code all day with intense concentration which is challenging from a vision and mental perspective.

In combination with bad sleep habits, not drinking enough water, eating unhealthy food, constantly rushing deadlines might result in headache and stress.

What we could do to prevent headache is:

  • take regular short breaks to give your eyes and brain a rest
  • going for walk. Walking outside will clear your head, improves your productivity and give you fresh energy
  • live more active live - include sport and stretching in your daily routine
  • focus on small things like: drinking a cup of water, stare at distant object, afternoon nap or chat with colleague.