You've received lots of great advice already. I'll only add...something that used to impact my inability to sleep after fasting was ironically my post fast water drinking tapered off at times. Also when I used to run athletically, if I did not have enough electrolytes in my system I wasn't able to sleep. It seemed when I made sure I was properly hydrated before, during & after exercising lack of restful REM sleep was no longer a problem.
Something to consider. Are you remaining properly hydrated with fresh squeezed fruit, green juices, water etc? Or are you eating enough hydrating foods...juicy fruits, raw/steamed vegetables and greens?
I find wheatgrass juice & coconut water are excellent natural remedies for insomnia. Wheatgrass creates healthier blood and coconut water is especially very hydrating. If you can purchase thai young coconuts and break them open for the water this is ideal vs. relying on the packaged brands. A bonus is you can use the coconut meat for desserts or add it to your fruit or green smoothies.
Deep stretching, deep breathing, yoga, meditation and/or soaking in a warm bath before going to sleep and using essential oils (ie lavendar, rose, sandalwood) might also help.