Usually due to sleep
Hypnagogic hallucinations are exclusive to the onset of sleep.
They should never occur when awake and alert. They are more common than you think but usually associated with sleep deprivation
. If you feel you are not getting enough good sleep, try improving that first. If it continues, talk to your doctor.