Totally anecdotal, but I went through a period of insomnia a few years age. It would take several hours to get to sleep. I realised that I had recently started taking vitamin D supplements just before bed and figured it might be connected.
Changed to take the supplements in the morning and the insomnia went away.