Got a migraine while coding

Hey guys i was going througn the basic javascript challenges after finishing the responsive web design projects and challenges, now i can’t continue because i got this migraine which is keeping me from going further.
Tried taking meds, resting and staying away from the computer for a few hours but that didn’t help. Any suggestion that’ll help me kill the migraine would be useful. I really need to get back to coding

Try taking longer breaks.

You might need more rest to get up going sitting in front of a computer.

1 Like

Hi there, I’m one of those people who get headaches for almost anything.
Car sick = headache
not enough sleep = headache
no caffeine = headache
allergies = headache
bad lighting = headache
looking at the same thing to long = headache.

There are few things that can give you a headache when coding.
1. Your lighting is bad.
This is unarguable the #1 thing to watch out for when programming for long periods of time. You don’t want glare or bad lighting. If you can see things on your monitor being reflected, then you should/move your monitor to a better position. For example, having a window behind you, is bad, since it can produce more glare than if a plain wall was behind you.
If your in the complete dark (like a real hacker) and your screen is blaring white at you, turn on a light to balance things out, or use a dark theme/ turn down the brightness. You don’t want to strain your eyes with to much direct light.
To much artificial light will give you a headache if your sensitive to it (like me). Go near a window and relax your eyes with real light from the sun. There’s a thing call the 20-20-20 rule to help. Every 20 minutes, look 20 feet away for 20 seconds, and just let your eyes relax.

I personally always have a natural light source near me during the day (a window in-front of me or to the side), or use a lamp at night (again to the side or in-front of me so no glare). I also use dark themes on legit everything possible. Darker themes are easier on the eyes, use up less battery and look more awesome :dark_sunglasses:

2. Your thinking to much
It’s very possible your pushing yourself to hard. Take your mind off things, go outside and just relax. Or take a quick 45 min nap to rest your brain/eyes. Pro-tip if you take a nap with a problem in mind, odds are you will wake up with new insight. You might be dreaming, but your brain will be doing its job of connecting random “thoughts” and you might be able to get something out of it when you wake up from the nap :smiley:

3. Do you need glasses?
This might be obvious, but worth mentioning. If you are having a tough time actually seeing, you might give yourself a headache, and you might need glasses. Heck you might need glasses but aren’t wearing them for some reason. Definitely something to double check. I get an eye exam once a year since I spend most of my days looking at screens. (I don’t wear glasses and don’t plan on getting them any time soon!)

*4. Your posture is bad
Ok hear me out, you might be like “how is my posture giving me a headache?”. It’s very possible your not relaxed in some way. This is more likely if your just starting out since your not used to sitting for long periods of time.

One thing that affected me was my neck, which resulted in headaches (as do most things). If your working on a laptop for a long period of time (coding or otherwise) your neck is very vulnerable since its most likely looking down at a non optimal angle. That or your slouching (which isn’t good either).

Another thing to mention is how close you are to the screen. optimal distance between your eyes and a screen is arms reach, when the middle of screen is at eye level. So if your on a laptop odds are it’s much closer.

Finally if your clenching your teeth, you can give yourself a nasty migraine. Be sure to relax yourself when working, no matter how teeth clenching the bugs are, gotta stay cool haha.

5. No caffeine?
This one is more of a lifestyle one. If your an avid coffee drinker, you could be having withdraws. I only bring this up because its possible you made a few life changes (like learning to code :smile:) nd dropping caffeine might be one.

Finally, I wanted to mention none of these might actually be the solution, they are just what I’ve found to give me headaches/migraines. It’s important to find out what is actually causing it, as getting migraines often while programming is not normal. Don’t go out and think “only real programmer program so hard they hurt themselves!” haha.
your health is more important than anything, so be sure to take care of it :smiley:

2 Likes

Dehydration is one of the biggest migraine triggers. Even if you are not drinking alcohol, a few too many cups of coffee can trigger a migraine. If you are drinking, alternate an alcoholic beverage with a glass of water. Watch out for certain types of alcohol, like red wine, champagne and whiskey, which are known to trigger migraines. Some scientists blame headaches on impurities in these alcoholic beverages, such as the higher concentration of sulfites in red wine. Some researchers believe champagne is a common migraine trigger because the bubbles carry alcohol into the bloodstream faster.