I had chronic insomnia for several years. But then I’ve stopped coding right before sleeping at least 1-3 hours in advance and now I can finally sleep. Who would’ve thought.
I am just finding that out now. I read something that it could be due to the blue light from LED screens, TVs, phones, etc. I hope to end my insomnia too.
Blue light before bed has been clearly shown to affect circadian rhythms and sleep. Some references here to get you started: