See a doctor if insomnia makes it hard to function during the day, if the inability to sleep persists for over a month, or if it occurs with other medical conditions or mental health disorders. A doctor can check for underlying issues and refer you to a sleep specialist if needed.