I believe the best thing first is to talk with a Doctor and/or a Psychologist, because it can either be something in your body that is out of balance or thoughts that get your brain and nervous system all hyped up. In addition, long walks or exercise (nothing strenuous to hurt yourself) during the day and meditating when you go to bed, do tend to help the body release whatever extra energy you accumulate and relax to fall asleep. Hope this helps 🙂
As someone who has dealt with onset insomnia for years here are the things I've found helpful. 1) Seriously, no screens. 2) Valerian root tea helps, but proceed with caution if you have issues with dreams. 3) Don't lie in bed — get up, go somewhere else and read or journal then try again later.
In tracking my mood against my habits, the thing that had the highest correlation to my sleep is my exercise.