If you’re lying awake night after night, the most effective thing you can do is rebuild your brain’s association between your bed and sleep. That sounds simple, but it involves specific behavioral changes that outperform sleeping pills in clinical trials. The techniques below work for both occasional sleeplessness and chronic insomnia, which is formally defined as trouble falling or staying asleep at least three nights per week for three months or longer.
The 20-Minute Rule
The single most powerful habit change for insomnia is counterintuitive: get out of bed when you can’t sleep. If you’ve been lying awake for roughly 15 to 20 minutes, get up, go to another room, and do something quiet like reading, listening to calm music, or watching something low-key. Don’t watch the clock obsessively. If it feels like it’s been about 20 minutes, that’s close enough.
Return to bed only when you feel genuinely sleepy. If you wake up in the middle of the night and can’t fall back asleep within that same window, get up again. Repeat as many times as necessary. This technique, called stimulus control, retrains your brain to associate your bed with falling asleep rather than with frustration and wakefulness. It can feel brutal for the first week or two, but it’s one of the most well-supported strategies in sleep medicine.
One important rule: don’t sleep on the couch. The goal is to make your bed the only place you sleep.
Compress Your Time in Bed
If you’re spending nine hours in bed but only sleeping six, your sleep is diluted. Sleep restriction therapy works by temporarily limiting your time in bed to match your actual sleep time, then gradually expanding it as your sleep improves.
Start by keeping a sleep diary for a week. Each morning, estimate how long you actually slept (not how long you were in bed). Then calculate your sleep efficiency: divide your total sleep time by your total time in bed and multiply by 100. If you slept 5.5 hours out of 8 hours in bed, your sleep efficiency is about 69%.
Set a fixed wake time and count backward from it by your average sleep time. That’s your new “sleep window.” So if you average 5.5 hours of sleep and need to wake at 6:30 a.m., don’t get into bed until 1:00 a.m. This feels extreme, and you’ll be tired at first, but the sleep pressure builds quickly.
After a week, adjust based on your efficiency score. Below 80%, shrink the window by another 15 to 20 minutes. Above 85%, expand it by 15 to 20 minutes. Between 80% and 85%, keep it the same. Over several weeks, your sleep consolidates into a solid, unbroken block, and your time in bed gradually increases to a normal range.
Fix Your Sleep Environment
Your bedroom should be cool, dark, and boring. Most sleep experts recommend a temperature between 65 and 68°F (18 to 20°C). A room that’s too warm disrupts the natural drop in core body temperature your body needs to fall asleep.
Light matters more than most people realize. Your brain’s sleep hormone, melatonin, is suppressed by light exposure, particularly short-wavelength light in the blue range (around 460 to 480 nanometers), which is exactly what screens emit. But research from a large study published in PNAS found that even ordinary room lighting with warmer tones can suppress melatonin through your eye’s cone receptors during the first 90 minutes of exposure. The practical takeaway: dim all the lights in your home for at least an hour before bed, not just the blue ones. Night mode on your phone helps, but it’s not enough on its own if your overhead lights are blazing.
Build a Consistent Sleep Schedule
Your body’s internal clock responds to regularity. The most important anchor is your wake time, not your bedtime. Pick a wake time and stick to it every day, including weekends. Sleeping in on Saturday morning feels restorative, but it shifts your circadian rhythm and makes Sunday night insomnia almost inevitable.
Morning light exposure reinforces this rhythm. Getting bright light (ideally sunlight) within the first 30 to 60 minutes after waking tells your brain to start the countdown toward sleepiness roughly 14 to 16 hours later. If you wake before sunrise, a bright light therapy lamp rated at 10,000 lux can substitute.
What to Do About Caffeine and Alcohol
Caffeine has a half-life of about five to six hours, meaning half the caffeine from your 2 p.m. coffee is still circulating at 8 p.m. For most people with insomnia, cutting off caffeine by noon makes a noticeable difference within a few days. This includes tea, energy drinks, and chocolate.
Alcohol is trickier because it genuinely makes you feel sleepy. But as your body metabolizes it, typically three to four hours after your last drink, it fragments your sleep and suppresses the deeper stages of sleep your brain needs for restoration. If you’re struggling with insomnia, even a single drink within three hours of bedtime can measurably worsen your sleep quality.
Supplements and Medications
Melatonin is widely used but often misunderstood. It’s a timing signal, not a sedative. Taking 0.5 to 1 mg about 30 to 60 minutes before your desired bedtime can help if your sleep schedule is shifted later than you want, but it won’t knock you out. Higher doses (5 to 10 mg) aren’t more effective for most people and can cause morning grogginess.
Magnesium supplementation has shown modest benefits for sleep quality in some trials. A pilot study using 1 gram per day of a magnesium supplement over two weeks found improvements in sleep quality compared to placebo, though the evidence base is still small. Magnesium glycinate is the form most commonly recommended for sleep because it’s better absorbed and less likely to cause digestive issues than other forms like magnesium oxide.
Prescription sleep medications, including drugs like zolpidem and eszopiclone (sometimes called Z-drugs), work by slowing brain activity. They can help in the short term, but they carry real risks. The FDA added warnings in 2019 about complex sleep behaviors, including sleepwalking, sleep driving, and sleep cooking, that can occur even at low doses and even after the first use. People typically don’t remember these episodes the next morning. These medications also cause next-day drowsiness that can impair driving. They should never be combined with alcohol or over-the-counter sleep aids.
When Insomnia Points to Something Else
Not all insomnia is a standalone problem. If you snore loudly, wake up gasping for air, or feel exhausted despite spending enough time in bed, sleep apnea may be the real issue. Risk factors include a large neck circumference and enlarged tonsils. A sleep study can diagnose this, and treating the apnea often resolves the insomnia entirely.
Thyroid disorders, restless legs (an uncomfortable urge to move your legs that worsens at night), anxiety, and depression can all cause or worsen insomnia. Blood tests and a physical exam can rule out these underlying conditions. If you’ve tried behavioral strategies consistently for several weeks without improvement, a medical evaluation is a reasonable next step.
Putting It All Together
The behavioral strategies described here, particularly stimulus control and sleep restriction, form the core of cognitive behavioral therapy for insomnia (CBT-I), which is recommended as the first-line treatment ahead of medication by every major sleep medicine organization. You can work through CBT-I with a therapist, through structured online programs, or by applying the techniques on your own.
Most people see significant improvement within three to six weeks. The first week or two often feel worse because you’re spending less time in bed and building up sleep pressure. That discomfort is the point. Your brain is relearning that bed means sleep, and that process requires some short-term deprivation to reset the pattern. Stick with it through the rough patch, and the results tend to be more durable than anything a pill can offer.

