This article originally appeared on Time.
You’ve craved sleep all day. You fell asleep watching Netflix. But the second you get into bed you’re wide awake.
Lying in bed unable to fall asleep is often called conditioned or lured arousal, says sleep-medicine specialist Philip Gehrman, an assistant professor of psychiatry at the University of Pennsylvania. It’s one of the most common sleep problems, and experts think it happens because something in your sleep environment has told your brain that getting in bed should “arouse” you or wake you up, instead of put you to sleep.
“If someone is a good sleeper, then each night they probably get in bed and fall asleep. So when they get into bed it triggers this auto response of sleepiness,” Gehrman says. “But if you spend night after night tossing and turning not being able to fall asleep, then your body associates that with your bed instead.”
There are plenty of obvious things that can trigger tossing and turning, and thinking about work right before you try to wind down is one. Using a laptop in bed, which creates the idea of the bed as a place for work or entertainment, is another.
But even those with normally good sleep habits can get thrown into this kind of sleep cycle after a stressful event—a job loss, say, or the death of a loved one, according to Dr. Ronald Chervin, director of the University of Michigan Sleep Disorders Center. Worrying disrupts your sleep, and that pattern can cause your brain to associate your bed with wakefulness in the same way it would if you were using a laptop.
It’s sometimes called ” psychophysiological insomnia ” and o nce it starts, the cycle of sleeplessness tends to perpetuate itself.
The most effective way to treat it, say sleep experts, is through cognitive behavioral therapy for insomnia, or CBT-I. This typically involves regular visits to a clinician and is aimed at changing your sleep schedule and habits. “A key part of what we teach people is to keep the bed for sleeping,” says Chervin. Of course, you can still have sex in bed, he adds, but you should try to move other activities elsewhere.
That means no screen time and no lying around if you can’t sleep. Even limiting reading is a good idea. “If you’re awake in bed for 20 minutes or longer, get up and go do something else,” Chervin says. Don’t get back into bed until you feel genuinely ready to sleep.
Re-training your brain to see your bed as a place for sleep can take some time, Chervin and Gehrman explain, but if you find and stick with a routine that makes you tired before getting into bed, you should be able to stop the cycle. Most people who use CBT-I attend between four to eight sessions, so give yourself a few weeks before expecting to see a change. I f you don’t live near a sleep clinic, Chervin says he has seen some patients use apps like SHUTi or Sleepio to do an at-home version of the therapy. Whatever your method, experts say it’s also important to follow general sleep advice such as keeping your bedroom at a comfortable temperature, avoiding coffee and alcohol late in the evening and dimming the lights before bed.
For those who don’t think they have insomnia, Gehrman says feeling sleepy until you lie down might also be a sign you’re a night owl who has a naturally later body clock than other people. “Some people want to go to bed at 10, 11 o’clock, but their bodies are wired so that when want to be going to bed they get a second wind,” Gehrman says. “Then it’s tough for them to awake in the morning because their body thinks they should still be asleep.”
Fortunately, there are ways to shift your body’s clock earlier so that by the time you get in bed you can successfully fall asleep. An important step is avoiding bright lights in the hour before bed, says Gehrman. Light, especially the blue light given out by computers and phone screens, suppresses the production of melatonin, a chemical that helps your body sleep. The other main fix is to develop a consistent wakeup time so your body can get used to the rhythm you want. While this means you shouldn’t sleep in on the weekends, the steady pattern in the morning will be worth it when it helps you feel sleepy by the evening.