It’s, oh, I don’t know, 3 o’clock in the freaking morning, and I’m lying in bed, flipping my pillow around in frustration. I’m trying to stay hopeful that I can catch a few hours of shut-eye before I have to get up.

But I’ve been through this enough times to know the beast of insomnia can’t always be tamed.

I’m not alone. Insomnia is incredibly common in the United States. According to the American Academy of Sleep Medicine, about 30 percent of American adults have some type of insomnia, and it’s more common in women than in men.

For anyone out there who has developed an expertise in fruitlessly counting sheep, we’ve rounded up a few strategies for finally catching those long-lost Zzz’s. And if you’re reading this at 3 a.m. because your mind won’t stop racing, don’t worry.

We have tips for what you can do right now to improve your chances of getting (at least some) sleep.

Insomnia is the inability to fall asleep, stay asleep, or get the amount of sleep you need to wake up feeling rested. Insomnia can be acute (lasting one to several nights) or chronic (occurring three times a week for at least three months). Walia HK, et al. Overview of common sleep disorders and intersection with dermatologic conditions. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4881480/ Its symptoms include:

  • difficulty falling asleep
  • frequent wake-ups during the night
  • waking up too early in the morning
  • daytime sleepiness
  • difficulty concentrating
  • irritability

The causes of insomnia range from a variety of underlying medical or psychiatric conditions to medication side effects to simple lifestyle factors. So a little detective work is your first step. Try some of the tips below to rule out lifestyle factors that may be behind your sleeplessness.

Insomnia is no joke. It can reduce your life expectancy and increase your risk of heart problems, compromised immunity, obesity, diabetes, seizures, and asthma. It’s probably well worth the effort to make some changes now to improve your sleep.

One possible reason you’re not getting enough rest is that your bedroom isn’t optimally set up for sleep. The ideal climate is cool, dark, and comfortable.

1. Invest in a good mattress and pillows

Uncomfortable bedding can lead to poorer sleep quality. A comfortable mattress increases your chances of a satisfying snooze. Check out the National Sleep Foundation’s tips on choosing the right pillow.

2. Dim the lights before you go to bed

Exposure to bright lights just before bed might negatively affect your chance of getting quality — and quantity — sleep. Light suppresses the secretion of melatonin, the hormone that influences your circadian rhythms and tells your body it’s night-night time.

Assuming you don’t want to sit in the dark for hours, find the happy medium by dimming the lights as bedtime draws near.

Also consider changing your light bulbs to ones with a “color temperature” of less than 3,000 kelvins. These soft/warm varieties can reduce the light’s effects on your nervous system.

3. Turn off screens

The artificial (or “blue”) light emitted by screens can disrupt your body’s preparations for sleep by stimulating daytime hormones. Reduce your exposure by turning off TVs, phones, and computers at least an hour before bedtime.

If you can’t get away from blue lights before bedtime, consider making a small investment in blue-light-blocking glasses.

Can’t sleep but don’t want to give up late-night TV? At least dim the screen’s brightness, either manually or with the help of automated programs.

4. Minimize disturbing noises

Some outside noises — like a busy street or a neighbor’s barking dog — are beyond your control. Cover them up with the sound of a bedside fan, a white noise machine, or other sounds that help with sleep.

5. Keep it (dark and) cool

A dark, cool bedroom environment helps to promote restful sleep. Program the thermostat so that your bedroom’s temperature is between 60 and 75°F. Experiment to find out what temperature works best for you.

Use heavy curtains, blackout shades, or an eye mask to block lights. Charge your phone and laptop outside the bedroom — even the tiny bit of light from a charging device can disrupt sleep.

6. Ban work from the bedroom

Beds should be used only for sleep and sex — nothing else. Bringing work into the bedroom is a surefire way to discourage quality sleep.

Prime your body with the same sleep-promoting activities each day. Eventually, they’ll become habit, and so will awesomely restful sleep.

7. Stick to a schedule

Try to stay on the same sleep-wake schedule, even on weekends. If your alarm goes off at 6 a.m. Monday through Friday, set it for the same time on Saturday and Sunday. The early alarm might make you groan, but you’ll sleep better for it.

8. Set aside “worry time” during the day

Every day, spend about 15 minutes addressing problems, so they don’t sneak up when your head hits the pillow. Schedule tasks and resolutions in your calendar. If a particular stressor is keeping you up at night but has a clear end date, this can help get it off your nighttime mind.

9. Keep track

Record how much and when you sleep, your fatigue levels throughout the day, and any other symptoms you have. Sleep-tracking apps like SleepScore and Sleep Cycle can help with your recording efforts.

Sleep tracking serves two purposes. It can identify things you do that help or hurt your chances of a good night’s rest, and it’s a useful tool for a doctor or therapist, should you decide to see one.

A healthy body equates to healthier sleep. Take good care of yourself overall with a balanced diet, exercise, and good stress relief, and you’ll have fewer worries come bedtime.

10. Don’t smoke

Need another reason to quit? Smokers commonly exhibit symptoms of insomnia — possibly because their bodies go into nicotine withdrawal during the night. Jaehne A, et al. How smoking affects sleep: A polysomnographical analysis. DOI: 10.1016/j.sleep.2012.06.026

11. Exercise

Moderate aerobic activity can improve both sleep quality and quantity. For best results, exercise at least three hours before bed so your body has enough time to wind down before you hit the sack.

12. Limit caffeine

It’s tempting to reach for coffee when you’re tired after a poor night’s sleep, but drinking caffeine can make it harder for you to fall asleep at night, creating a vicious cycle.

Research has shown that people who consume more caffeine spend less time sleeping and don’t sleep as well as those who avoid overdoing caffeine [Watson EJ, et al. (2016). Caffeine consumption and sleep quality in Australian adults. DOI: 10.3390/nu8080479].

Can’t quit cold turkey? Try limiting caffeine to earlier in the day so it’s out of your system by bedtime.

13. Nap the right way

Just 10 to 20 minutes of napping during the day can help you feel more rested. A good power nap can improve your creativity and memory, too! But avoid snoozing any longer than 20 minutes, which could steal time from your nighttime slumber cycles.

14. Get outside

Increasing your exposure to natural light during the day promotes a healthy balance of that sleep hormone, melatonin. Sunlight tells those ancient receptors inside your body that it’s time to get going with the hunting and foraging and all things not sleep.

This helps reinforce the message to do the opposite when it’s dark.

15. Eat for sleep

Magnesium and B vitamins are two nutrients that may help enhance your sleep. Foods high in magnesium include:

  • halibut
  • almonds and cashews
  • spinach

Also eat foods like these, which are rich in B vitamins:

  • leafy green vegetables
  • nuts
  • legumes

16. Consider natural supplements

Valerian, tryptophan, and melatonin are three supplements used to promote sleep, but their effectiveness varies. Research shows that melatonin can help you fall asleep a bit faster and keep you slumbering longer, but results can vary a lot based on which product you buy. Abad VC, et al. (2018). Insomnia in elderly patients: Recommendations for pharmacological management. DOI: 10.1007/s40266-018-0569-8

Check with your doctor before taking any supplement, to make sure it’s safe for you.

17. Vent stresses

If designated worry time earlier in the day didn’t fully do the trick, spend some extra time writing down your anxieties. Loose-leaf paper works, but if you scrawl your sorrows in a journal or notebook, you can literally close the book on your worries (at least until morning).

Don’t jump straight from your last activity of the day into bed. Give your mind and body a chance to prep for sleep.

18. Try relaxation techniques

You’ve probably heard that meditation seems to be good for us in just about every possible way. One meta-analysis found that people who practiced meditation saw improvements in total sleep time and sleep quality.

Other relaxation strategies — like yoga, deep breathing, and progressive relaxation — are also effective tools for promoting good sleep.

19. Avoid large meals late in the evening

A big meal before bedtime could leave you too stuffed to sleep. Just getting horizontal can create that burny feeling in your throat. Everything slows down during the night, too, and it’s probably not great to have all that food sitting around in your digestive system.

20. Don’t drink alcohol right before bed

Booze might seem like an obvious choice for calming down pre-bedtime, but it can actually disrupt sleep cycles later in the night. You don’t have to give up the good stuff completely. Just drink it with dinner (around 6 o’clock) and skip the nightcap.

21. Turn off your brain

Don’t work, watch super-stimulating TV shows or movies, read complex material, or think too hard — about anything — before bedtime. See above about getting away from your screens. Working out your brain keeps your body awake.

22. Have sex or masturbate before bed

Hey, anything for a good night’s rest. Getting your “O” face on pre-bedtime can help you fall asleep. Why not?

23. Don’t try to sleep unless you’re sleepy

Yes, it sucks when it’s 2 a.m. and you still don’t feel tired despite knowing you need rest. But climbing into bed when you don’t feel ready for sleep is setting yourself up for failure.

Instead, engage in relaxing activities (like gentle yoga and meditation or listening to soothing music) until you get the strong urge to snooze. If sleep hasn’t come within 20 minutes, get back out of bed and try relaxing activities again until you’re sleepy enough to give it another go.

24. Brew some chamomile tea

This soothing tea has a calming effect on your brain. A cup or two could get you into a better headspace for sleep.

25. Try a warm bath or shower

Stepping from warm water into that pre-cooled bedroom will cause your body temperature to drop slightly. This temperature change triggers sleepy feelings by slowing down your body’s metabolic activity.

26. Sip some hot milk

Science doesn’t necessarily back the idea that milk facilitates snoozing. But if you’ve been in the habit of milk before bed since childhood, the suggestion of sleepiness from a cup of warm milk might be strong enough to get you there.

27. Do some leg exercises

You might wonder if this advice contradicts the “no exercise before bed” warning. But some easy leg lifts, squats, or your leg exercise of choice can help divert blood flow to your legs and away from your brain. This can quiet your mind, making it easier to slip into dreamland.

28. Count some sheep (seriously)

It might not work for everybody, but focusing on one thing can help settle down your brain, making sleep easier. Not a fan of these wooly animals? Focusing on your breath (in, out, in, out) is also an effective way to chill out.

29. Visualize yourself asleep

Imagine yourself drifting into a blissful slumber while practicing deep breathing and progressive muscle relaxation: Starting at one end of your body and working your way up or down, clench and then release each section of muscles for instant all-over relaxation.

Tried everything and still can’t sleep? It may be time to reach out to the pros for advice.

30. Get some therapy

Cognitive behavioral therapy for Insomnia is a pretty common technique. Also called CBT-I, this therapy typically involves self-monitoring, mental strategies (like developing positive thoughts about sleep), and creating an environment that promotes sleep.

Research has shown that it can improve the quality of sleep. Morgan K, et al. (2012). Self-help treatment for insomnia symptoms associated with chronic conditions in older adults: A randomized controlled trial. DOI: 10.1111/j.1532-5415.2012.04175.x

Learn these strategies with the help of a therapist or with online guidance or books — both are equally effective ways of implementing CBT-I. Not into seeing a therapist? Use a digital program like Sleepio to help you learn and implement CBT practices from the comfort of your home.

31. Talk to your doc

If you’ve tried everything and sleep remains elusive, it might be time to consult a healthcare professional. A doctor can help rule out any sleep disorders and identify health issues, treatments, or medications that might be getting in the way of a good night’s rest.

What definitely won’t do you any good in the getting-to-sleep department: judgments (“I should be asleep”) and catastrophic thinking (“If I don’t get to sleep, I’ll mess up that presentation tomorrow, lose my job, and die tired and alone”).

Make the night easier by accepting insomnia for what it is. Let go of judgments and be gentle with yourself. The silver lining? You just might get to see a glorious sunrise.