There is some trigger to ur this condition and ur mind has stored this. Not getting sleep is due to this trigger Which is a suncomcious process. Mind is alert due to some anxious thought giving rise to fear, which is called a flight mechanism and u land up staying awake coz concious mind is not aware what's happening. Which is also called a sympathetic response to the environmental factors acting on our psyche or mind.
Next Steps
Try and work on it thoughts and think of positive thoughts.
Health Tips
Breathing exercise, meditation. see a psychologist if possible for better recovery. Few Regression tgerapy will resolve issue.