The short version: If you can’t sleep, start by ruling out drugs (eg coffee, alcohol), other psychiatric disorders, circadian rhythm issues, or trouble getting to bed on time for psychosocial reasons. Once those are cleared up, practice good sleep hygiene, eg making sure your bedroom is cool, dark, and quiet (and maybe try a weighted blanket!). If that doesn’t work, consider doing insomnia therapy with a therapist or an app like Insomnia Coach. If that doesn’t work, consider using supplements like melatonin, l-theanine, or cannabis. Sleeping pills are last-line due to issues with tolerance and side effects, but if you need them you can start with trazodone. Heavy hitters like z-drugs are best taken occasionally rather than every night.
The long version:
1. What is insomnia?
Insomnia is a “wastebasket diagnosis” – it’s what we call sleep problems if we don’t have a good explanation for them. You can always brute-force the treatment of insomnia with sleeping pills, but it’s usually safer and longer-lasting to figure out the underlying problem. Before I try anything fancy for insomnia, I ask patients to check if they have any of the following simple problems:
– Do you stay up all night ruminating and being anxious? In fact, are you anxious and ruminating all through the daytime too? If so, you might have an anxiety disorder, not insomnia per se. Once you treat the anxiety, you’ll be able to sleep just fine.
– Do you have a time you could easily sleep, but your schedule makes it impossible for you to sleep then? For example, some people naturally feel wide awake until 5 AM, then naturally start feeling sleepy around that time. Other people might naturally feel sleepy at 7 PM, but they force themselves to stay up until midnight, at which point they aren’t tired anymore. These people might sleep fine if they were allowed to set their own hours, but aren’t able to handle the schedule imposed by a 9 to 5 job. If so, you might have a circadian rhythm disorder, not insomnia, and you should try a circadian protocol of melatonin.
– Do you use stimulants – coffee, Adderall, Ritalin, etc? Are they interfering with your sleep? Are you sure they’re not interfering with your sleep? I’ve had so many patients who swear that their coffee doesn’t affect their sleep because they only drink it in the morning and it’s out of their system by the early afternoon – and then as soon as they stop drinking coffee their sleep problems miraculously resolve. I don’t have a great pharmacological explanation for why this should be, but I recommend that you experiment with quitting coffee before trying anything else to resolve sleep issues.
– Do you drink lots of alcohol, especially around bedtime? If so, the alcohol might be interfering with your sleep. Try stopping alcohol for a month and see if your sleep problems improve. If you can’t stop alcohol for a month to test if your sleep problems improve, you may have alcoholism and not insomnia.
– Do you stay up until long past your bedtime doing exciting things like browsing the Internet and playing video games, then have little trouble getting to sleep once you finally turn out the lights? If so, you don’t have insomnia, but you might have a video game addiction. Other people do this because they feel like they have no free time and the only way to get an hour or two to themselves is to cut into their sleep. This is a hard problem with no good answers, but it isn’t insomnia.
If none of these apply to you, but you still can’t get to sleep, then you might have insomnia.
2. What are the types of insomnia?
Initial insomnia means you can’t get to sleep.
Middle insomnia means you wake up in the middle of the night and have trouble getting back to sleep. There’s some debate about whether or not this is natural. There’s a lot of evidence that people in pre-industrial societies practiced “biphasic sleep” – they naturally slept for about four hours, woke up for an hour or so, then went back to sleep for another four hours. If you’ve always had this pattern and it doesn’t bother you, there’s no reason to try to “cure” it. If you’ve gradually developed this pattern, it might be worth seeing whether you can live with it. But if you’ve suddenly developed this pattern and find it’s incompatible with your routine, it’s probably fair to try to see if you can quash it again.
Terminal insomnia means you wake up very early in the morning and can’t get back to sleep. If you’ve always done this and feel well-rested, it’s not a problem – it just means that you don’t need much sleep. If this is new and makes you feel tired, then it might be a problem. This pattern is absolutely typical of depression, and should be considered a depressive symptom until proven otherwise (if you’re not feeling depressed, then you’ve proven otherwise). If it’s not depression, it might be a circadian issue; consider changing the time you go to sleep or taking melatonin.
Most of this page will assume you have initial or middle insomnia. Terminal insomnia that isn’t depressive or circadian can probably be treated as middle insomnia that occurs very late in the night/morning.
My algorithm for treating initial or middle insomnia is: sleep hygiene, calming exercises, therapy, supplements, medication.
3. What is sleep hygiene?
Sleep hygiene means creating an environment conducive to sleep. You can use the following checklist:
1. Is your room dark enough when you’re trying to get to sleep? In theory, darker rooms mean better sleep. I don’t know of very good research on this – is a nightlight ruining your sleep? What about the little indicator light on your electronic devices? Obayashi, Saeki, and Kurumatami have a kind of weak correlational study where they find a trend for brighter rooms to mean worse sleep. Eyeballing their data, I see no difference between the darkest rooms and rooms up to about 1 lux, a possible difference around 2 lux, and a clear difference around 10 lux. 1 lux is about the brightness of a moonlit night; 10 lux is about the brightness of a candlelit dinner. My guess is that hunting down the last tiny glints of light isn’t necessarily useful, but everything short of that is. If you can read text in your bedroom after lights out, it is much too bright. I recommend blackout curtains and putting tape over every device light. If some light is unavoidable, consider a sleep mask. Some terminal insomnia is caused by light coming through your windows too early; if you notice this, black out your windows or get a sleep mask.
2. Is your room quiet enough?. Ambient noise can prevent the falling-asleep process (causing initial insomnia) or disrupt light sleep (causing middle insomnia). This is especially a problem for people living on busy city streets, and many people tell me their sleep and lives get much better when they move to less dense areas. If you can’t do that, buy a big box fan to produce loud white noise, get earplugs, or both. Most people who say they don’t think they could tolerate the feeling of something in their ears will take one or two nights to adjust, tops.
3. Are you avoiding bright light before bedtime? Bright light in the evening shifts your circadian rhythm into day mode and inhibits sleep later on. There are theoretical reasons to think blue light is especially problematic, though some studies find that white or yellow light is worse. Instead of participating in this debate, consider using red light, which everyone agrees is unlikely to cause problems. Although you should avoid staring at screens at night, if you have to do it, install f.lux, a program which will automatically redshift your screen in the evening and blueshift it again in the daytime. If possible, get circadian lighting in your bedroom – ie light bulbs which automatically switch from bluer and brighter in the day to redder and darker in the evening. Or if all of this sounds too hard, wear light-filtering glasses at night – “blue-blocking” won’t be enough, you should use ones which are actually deep red in color. You can learn more about which brands block which wavelengths here.
4. Is your room cold enough? Part of the process by which your circadian rhythm initiates sleep is cooling off core temperature; this is the sign for your body and brain to wind down and turn off. The cooler the ambient temperature, the easier this is. The National Sleep Foundation says the best bedroom temperature for sleep is 65 degrees. Various high-tech brain-cooling devices seem to treat insomnia very effectively; until they became more widely available, you will need to use low-tech solutions like fans or air conditioners. You might also want to look into cooling pillows, mattress cooling pads, or an entire (very expensive) cooling mattress.
5. Have you been active during the day? Intuitively, exercise “tires you out” in a way that helps you sleep at night; various studies appear to confirm. Exercising during a specific day helps you sleep better that night, and being generally fitter helps you sleep in general. According to this study, morning exercise might be more helpful; there is no sign that evening exercise disrupts sleep, but it might not help as much either.
6. Does your body associate your bed with sleep? In theory, you can condition your body to associate your bed with sleep by not doing activities (reading, using the computer, having sex) on your bed or even in your bedroom during the day. I have not been able to find any evidence confirming that this works; if you have this, please send it to me.
7. Do you go to sleep at a consistent time every night? In theory, this should help your body establish a circadian rhythm. I have not been able to find any evidence confirming that this works; if you have this, please send it to me.
8. Are you fretting about how late it is? Lots of people see that it’s ten minutes after the time they were hoping to go to sleep, or already past midnight, and panic over how little sleep they’re getting, or start thinking things like “I have to be asleep before 1” which make them keep checking the clock, sinking feeling in their chest. The easiest solution to this one is not to have a clock visible in your room while you’re in bed!
8. Have you tried a weighted blanket? This is a little further-out than some of the other suggestions on here, but a lot of people find it very helpful. You may have heard of these for autism or anxiety, but they seem to help in a wide variety of situations. See eg this article from the American Academy of Sleep Medicine. AASM recommends this brand as a good compromise between price and quality, but it still costs $129 for a queen bed size.
4. What kind of calming exercises help with insomnia?
Calming exercises are special techniques that some people find help them get to sleep. The oldest and simplest is counting sheep. Other classics involve imagining yourself at a mountain stream or some other “happy place”, or following a script to imagine a relaxing situation.
Some popular mindfulness apps like Headspace and Calm have calming exercises to help you get to sleep, and many of my patients have found them helpful. The Sleep Foundation has a few others at their site.
Here are three of my favorites:
1. Progressive muscle relaxation. Lie down on your back, sprawled out somewhat in a relaxing position, with your palms facing up. Start at your toes. While inhaling for five seconds, contract your toes as hard as you can, then exhale and relax them as much as you can. Notice how relaxed they feel and see if you can relax them even further. Then gradually move up, doing the same thing to your feet, ankles, legs, buttocks, core, torso, hands, arms, shoulders, neck, and face. When you’re done, stay in the same position, and either drift off to sleep or do one of the other exercises.
2. Sixty-one points. Lie down on your back, sprawled out somewhat in a relaxing position, with your palms facing up. Purposefully but gently direct your attention to the point in between your eyebrows, observing the sensations there. Then shift your attention through the rest of the sixty-one points spelled out on this list, until you reach the point between your eyebrows again. When you’re done, stay in the same position, and either drift off to sleep or do one of the other exercises.
3. Simple meditation. Lie down on your back, sprawled out somewhat in a relaxing position, with your palms facing up. Don’t move, at all, not even a muscle – total lack of movement is a pretty strong clue to your body that it’s time to sleep. Breathe in and out slowly and rhythmically. Concentrate on the feeling of your breath moving through your nostrils. If you notice your attention going to anything else – worries, plans, annoyances, uncertainty about whether you’re doing it right – gently turn your attention back to the feeling of your breath moving through your nostrils. Continue until you fall asleep.
The goal isn’t to do one of these, fall asleep instantly, or else get angry and pace around for a while fretting about how the calming exercise didn’t work. It’s to do one, feel a little more relaxed, and either gradually drift off to sleep from there or do another to become even more relaxed.
If you don’t sleep on your back, you’ll have to figure out how to adjust these. Some people find they can do these exercises on their side; other people find it’s easier to do them on their back, then gently turn on to their side once they feel like sleep is close.
5. What kinds of therapies help with insomnia?
The strongest evidence is for a therapy called CBT-i (cognitive behavioral therapy for insomnia). Some studies find it works as well or better than medication, while others find it may be less effective than medication initially, but more effective in the long term (ie after your body has developed tolerance to the medication).
Some of CBT-i is discussing things already mentioned in this essay, like sleep hygiene and calming exercises. But some other basic principles are:
1. Sleep restriction: Initial insomniacs tend to lie in bed awake a lot, and can get so accustomed to doing so that going to bed becomes a cue for “lie awake” rather than for “go to sleep”. Sleep restriction tries to ensure that you’re asleep for most of the time you spend in bed. So you and your therapist work together to set a beginning time in bed. Suppose you usually get in bed at 11, lie awake until 3 AM, and then sleep from 3 to 9. It seems like you’re sleeping 6 hours. So you and your therapist agree that your Official Time in Bed will be only from 3 to 9. You will stay up and out of bed until 3 AM, reading or watching TV or whatever, then go to bed at 3, set the alarm for 9, and wake up as soon as the alarm goes off. Probably you’ll be sleep deprived the next day; this is an expected part of the therapy. Hopefully you’ll be so sleep-deprived that when you go to bed at 3 the next night, you’ll fall asleep pretty quickly.
Every week, if and only if you slept for 90% of your time in bed the week before, you can push your bedtime backwards 20 minutes. So if you successfully slept from 3 to 9 every night of Week 1, you can go to bed at 2:40 AM every night of week 2. If that works out, you can go to bed at 2:20 AM on week 3, and so on. If you sleep less than 80% of your time in bed, then you push your bedtime forward 20 minutes. So if your Official Time In Bed was 2:20 to 9:00, but you consistently only fell asleep at 4:00, then of your 400 minutes in bed you are only sleeping 300 of them; 300/400 = 75%, so you would shorten your Official Time In Bed to 2:40 to 9:00 the next week and see how that goes.
The goal is that at the beginning, the sleep deprivation this therapy produces teaches your body to associate going to bed with falling asleep immediately, and the gradual change moves you back to your regular bedtime without breaking this association. Obviously this involves a lot of weeks of painfully low sleep, but studies have shown it does work.
2. Cognitive therapy: This is about trying to find dysfunctional thoughts that prevent you from sleeping. The basic principle is: the more desperate you are to go to sleep, the less relaxed you are, and the less likely you are to actually sleep. If you’re spending all night thinking things like “I need to go to sleep right now or I’ll be a wreck in the morning”, this part of the therapy can help you learn techniques for challenging those thoughts.
3. Paradoxical intention: Sometimes cognitive behavioral therapists recommend that patients try as hard as they can not to fall asleep, as a last-ditch way of breaking the cycle of trying so hard to get to sleep that they inevitably fail. I assume if you’re a sufficiently skilled therapist you know when this one is vs. isn’t appropriate.
— 5.1. Now that you told me what to do, do I still need a therapist?
I don’t think the above description is sufficient for you to do CBT-i on your own. But given that there are 60 million people with insomnia in the US but only 75 licensed CBT-i therapists, probably someone should be trying to help you do CBT-i on your own. There are now a couple of books and apps that offer to teach you about CBT-i in enough detail that you can do it to yourself. If it’s hard for you to get a real therapist, it might be appropriate to try using one of these.
Two meta-analyses found that online CBT-i through an app was as good as real CBT-i with a real therapist, and this is similar enough to results in other therapies that I’m predisposed to believe it. Other studies didn’t compare to face-to-face CBT-i, but were able to show that online CBT-i definitely beat placebo.
Many of the apps examined in the studies are prescription only. You can’t even begin to download them until you’ve paid hundreds of dollars and waited several months to get an appointment with a sleep specialist, the exact thing you were trying to avoid by using an app. As far as I can tell there’s no justification for this, it’s just another stupid counterproductive thing about the US medical system. I am boycotting the concept of “prescription apps” and so I will not be linking or reviewing any of these here, sorry.
In terms of books: Conquering Insomnia is a 5-week PDF based program by Dr. Gregg Jacobs, a professor of psychiatry with “30 years of experience” in sleep research, positively profiled in the New York Times. It costs between $50 and $70 at this sketchy-looking website.
If you don’t have $50 – $70, here is a free guide by Dr. Rachel Mauer, which definitely doesn’t hold your hand but gives you a bit more information than is available here.
In terms of apps: the gold standard are the US Veterans Health Administration’s CBT-i Coach and Insomnia Coach. My understanding is that both use CBT-i, but CBT-i Coach is designed to be used collaboratively by patients and a CBT-i therapist who they already have, and Insomnia Coach is designed to be used independently. Both are available to everyone, regardless of whether they are veterans or not. CBT-i Coach has lots of studies in support and rave reviews, Insomnia Coach seems newer and is less talked about. My impression is that Insomnia Coach is probably a good stand-alone CBT-i app, but I’d like to hear more from people who have used it or from sleep specialists who are better acquainted with it.
You can read more about the pluses and minuses of different CBT apps, books, and courses here.
6. What supplements help with insomnia?
Different ones will help different people! Remember, using supplements is always a process of trial and error. You should expect to have to try many different substances before finding the one that’s right for you. But here are my recommendations for what to try in what order:
1. Melatonin. 0.3 mg just before bed if treating initial insomnia, or a more complicated regimen if you’re treating anything else. See Lorien’s page on melatonin for more information.
2. L-theanine. The main relaxing component of green tea. Copious anecdotal evidence, a few small formal studies. Take 200 – 400 mg just before sleep.
3. Sleepytime Tea. Realistically a lot of these are also l-theanine, but some of them contain other useful chemicals, and some people prefer a tea to a pill.
4. Magnesium glycinate. Both magnesium and glycine have decent formal and anecdotal evidence of helping with sleep.
5. Cannabis products. All 50 states have legalized CBD , one of the cannabinoids in marijuana that doesn’t make you high, and many people find this helps their sleep. Some popular strains and extracts include Charlotte’s Web Sleep Gummies (warning: these also contain an excessive amount of melatonin), and Calm By Wellness (expensive but well-reviewed). Some people find that they sleep better with strains of cannabis with some THC (ie ones that do make you high); check your state laws before trying this. If you live in a state where cannabis is legal, the people at your local marijuana dispensary will be a valuable source of information.
Other potentially useful supplements you might want to experiment with: lemon balm, zinc, magnolia bark, oleamide, valerian, and anything that works for anxiety.
7. What medications help with insomnia?
When trying to help patients with sleep, I try to save medications for last. Although effective, some of them build tolerance. When you first take them they work very well, after you’ve been taking them a few months they don’t work at all, and when you stop taking them your sleep is even worse than before for a while. Not everyone will get tolerance on every sleeping pill, and some people seem blessed with an ability to avoid ever getting tolerance at all. I think probably fewer than 25% of people will get tolerance to trazodone, about 60% will get it to Ambien and other z-drugs, and maybe 80-90% will get it to benzodiazepines. These numbers are complete wild guesses with no backing in the literature, which just makes the easily-disprovable claim that all sleeping pills produce tolerance in everyone.
Also, many studies show that all sleeping pills raise all-cause mortality at alarming rates – even a few sleeping pills a year can make you several times more likely to die of cancer, heart disease, and almost everything else. Probably these studies are confounded; people who sleep poorly both take more sleeping pills and are generally sicker. Mediocre attempts to adjust for this confounder have failed to eliminate the effect; extreme attempts to adjust for these confounder have eliminated the effect, but are still awaiting replication. Right now I think taking sleeping pills probably won’t shave several years off your life, but until I’m very sure about that I will continue discouraging people from taking sleeping pills if they have any other options.
The best way to use sleeping pills is very occasionally. You are at low risk of tolerance if you take something once every couple of weeks, when you’ve had an especially hard day. Once you need sleeping pills every night, it might be time to go back a little in the algorithm and make sure you’ve tried all the calming exercises, CBT-i, etc that you can. A few people do manage to do okay on long-term sleeping pills, but it’s kind of a gamble to hope you’re one of them.
But if you absolutely have to – most sleeping pills are designed to kick in fast, then gradually wear off over the next eight hours in time to be out of your system in the morning. If you have central or terminal insomnia, you might want something longer-acting, so that there’s still a lot of it in your system in the middle of the night when you would otherwise be waking up. Doxepin and amitriptyline are the longest-acting sleeping pills and usually good for this, but the tradeoff is that they last so long that you might be tired all morning too. Other people go the other direction and want a short-acting sleeping pill they can take when they wake up at 3 AM, so that they can get back to sleep without being tired for the next eight hours. Sonata is ultra-short-acting and pretty good for this. But also, consider changing the dose of whatever sleeping pill you’re already on. A lower dose of a drug will be metabolized into irrelevance faster than a higher dose, so all else being equal lower doses will keep you asleep for less time. This method isn’t perfect; a very low dose might not get you to sleep at all, and a very high dose might be dangerous. But you can change things a little around the edges. Trazodone is especially good for this. If 25 mg of trazodone makes you wake up too early, and 50 mg makes you tired all morning, take 37.5 mg and sleep exactly the right amount of time. For some reason nobody ever thinks of this on their own, but it definitely works.
I usually try sleeping pills in a specific order – the plan is to start with the ones that have the fewest side effects and the least chance of developing tolerance, and then go up to ones that are more effective but also more likely to cause problems. That order loosely looks like:
1. Trazodone: An old-school antidepressant that kept putting people to sleep as a side effect and eventually got rebranded as a sleeping pill. Antidepressant doses are about 5-10x sleep doses, so taking it for sleep probably won’t help your depression. Take 25 – 100 mg just before bed; some people will be especially sensitive or resistant and need amounts outside that range. It doesn’t have many common side effects; one rare side effect (1 in 10,000 men) is priapism, an erection that won’t go away. If you get this it’s very serious and you need to go to the hospital immediately. Everyone always laughs when I tell them this, but this is serious business. There are scattered reports of female priapism (of the clitoris), but no known evidence that it can be dangerous in women.
2. Mirtazapine (“Remeron”): Also an antidepressant; this time the sleep dose and the antidepressant dose are pretty similar so it might treat your depression too. Take 7.5 – 15 mg just before bed; weirdly, higher doses are less effective for sleep! Mirtazapine will seriously increase most people’s appetite; expect to gain ~10 lbs on this unless you’re very lucky or very careful.
(2.5. Maybe gabapentin, diphenhydramine, hydroxyzine – I don’t really expect these to work if the last two have failed, but there might be room for them somewhere around this point.)
3. Zolpidem (“Ambien”): Effective, low risk of weight gain, patients seem to like it. But this is where the usual warnings about sleeping pills start to really hold true – high risk of tolerance development, high risk of trouble sleeping when you stop it, some possibility of increased mortality. Usual dose is 5 – 10 mg taken before bed. Side effects include sleepwalking, sleep-eating, sleep-driving, sleep-murdering, going on adventures with hallucinatory walruses, and spending $3,075 to buy a Tibetan yak. You’ve probably heard the same stories I have, but how common are these types of strange behaviors? Studies range from ~1% to ~3% to ~5% of patients experiencing some form of somnabulism or anterograde amnesia (ie doing things they don’t remember later). Most of the craziest stories I find online involve people taking Ambien overdoses or people taking Ambien together with alcohol or other drugs; avoid these problems and your odds will be better – but still not zero.
4. Other z-drugs: Zaleplon (“Sonata”) is more or less just Ambien but shorter-acting. Es-zopiclone (“Lunesta”) is more or less just Ambien with creepy moth-related ads. Sometimes people will find that one of these randomly works better than another based on their unique personal biochemistry. The drug review site Iodine finds that 67% of Ambien users are satisfied, vs. 55% of Lunesta users and 42% of Sonata users.
5. Quetiapine (“Seroquel”). Usually an antipsychotic, sometimes used for sleep at doses about 10% of the usual antipsychotic dose. This is controversial, with many people saying it should never be used for sleep and this is unsafe and outrageous. I agree it should almost never be used for sleep, but I will use it occasionally and temporarily for people who desperately need sleep and have failed to respond to anything else. As far as I can tell, low-dose quetiapine doesn’t really bind to D2 in any meaningful way and shouldn’t be considered an antipsychotic, which means some antipsychotic-specific concerns like tardive dyskinesia are less likely. However, it certainly causes weight gain and metabolic syndrome, even moreso than mirtazapine; you can expect to gain 10 – 20 lbs on it. Seroquel has a black box warning about increasing mortality in the elderly, and I would not use it for these patients.
6. Asenapine (“Saphris”). Another antipsychotic, with many of the same negatives as Seroquel, plus it costs $1,190 a month (insurance will not cover this for sleep). On the other hand, it’s effective enough that I’ve never needed to figure out a step 7.
I rarely use amitriptyline or doxepin, just because I haven’t seen too many patients who don’t respond to trazodone but do respond to these; I might use one of them if trazodone works but doesn’t last long enough. I rarely use benzodiazepines because tolerance to their hypnotic effects grows even more quickly than to their anxiolytic effects; z-drugs have more or less the same benefits but lower risk. I rarely use suvorexant (“Belsomra”), because it costs $384/month and has failed to impress me as appreciably better than other cheaper options. I rarely use ramelteon because it costs $102/month and isn’t clearly distinguishable from melatonin (it bills itself as a “melatonin receptor agonist”, but no studies have proven it agonizes melatonin receptors better than melatonin itself; also this is another one with an unnecessarily creepy ad campaign). I usually avoid diphenhydramine and hydroxyzine because of excessive concern about anticholinergic side effects, but if I knew they worked for a certain patient I would probably prefer them to the second half of the algorithm.
8. What if none of this works?
Around the point where you start taking z-drugs and Seroquel, I would recommend making an appointment with a sleep specialist to see what they think. Bay Area locals might want to try the UCSF Sleep Disorders Clinic; other people can find similar clinics at their local hospital, research university, or in private practice.