Migraine and insomnia are like the friends you know who are in a dysfunctional, drama-filled relationship, even though everyone else says it would be best if they broke up and went their separate ways.

About 50 percent of people who have migraine or tension headache also experience insomnia. This connection is what researchers call “bidirectional.” One issue can trigger the other and vice versa.

This dysfunctional relationship is made worse by the fact that insomnia means you’re missing valuable rapid-eye-movement (REM) sleep. Missing out on REM sleep may increase your sensitivity to pain.

I envy people who hit their pillow and instantly pass out. Most nights, you’ll find me 30 minutes in, tucked under my blankets and the crushing weight of my failure to sleep. But I’m trying some new things and I have hope.

Here are some research-backed solutions that may get you some more time in dreamland.

Tame your mind

I’m not doing myself any favors by devoting energy to anxiety instead of taking a trip to dreamland. To help, I’ll try some relaxation techniques, like breathing exercises or meditation.

I’ve also begun cognitive-behavioral therapy (CBT), which is considered an effective first-line treatment for chronic sleep problems. It helps you identify and change the thoughts and behaviors that sabotage your sleep.

Ask your health care provider to recommend a therapist trained in CBT or, even better, a sleep specialist.

Clean up your bedtime routine

I admit I hate the term “sleep hygiene.” But it just has to do with creating the best environment and conditions for getting to slumber town. The basic rule involves setting a regular hit-the-hay time that allows for 8 hours between the sheets dedicated to sleep.

That means most other activities should be done elsewhere. I’m talking about working on your laptop, bingeing on Netflix, scrolling through the Insta, listening to podcasts, even reading.

I say “most” because clearly you can enjoy certain ahem activities in bed.

Take some time to unwind before going to sleep. Try meditating, reading a book, journaling in a notebook, or something else relaxing that doesn’t involve looking at a screen.

A regular schedule is also intended to provide a set waking time since oversleeping can also trigger migraine pain. This why many people with migraine experience headaches on the weekend.

Schedule sips and eats well before bed

Plan to nosh your last meal or snack about 4 hours before you go to sleep.

Eating too close to Snoozeville can cause heartburn other gastrointestinal issues that might keep you awake. And avoid drinking too much liquid before bed, so you’re not woken up with the need to pee in the middle of the night.

Be mindful of your caffeine and booze intake too. Consuming caffeine late in the day can keep you awake into the wee hours — and keep you wee-ing. Alcohol, although a depressant, is linked to insomnia when used in excess.

Missing out on sleep is a totally normal, human thing to do now and again. But if lack of sleep is becoming your norm, talk to your doctor. They may recommend medications or supplements, or have other ideas for you.

And definitely see your doctor if you experience an increase in the frequency or severity of migraine attacks.

After implementing some of the above solutions, I’ve had better success with sleep, but it’s a work in progress. My relationship with sleep is still complex, which isn’t good news for my migraine.

But I feel better having some tools to help my body work through sleep issues, and I’m grateful for the mornings I do wake up feeling well rested. For the others, there is always espresso (but not after 12 p.m.).

Jennifer Chesak is a medical journalist for several national publications, a writing instructor, and a freelance book editor. She earned her Master of Science in journalism from Northwestern’s Medill. Jennifer lives in Nashville but hails from North Dakota, and when she’s not writing or sticking her nose in a book, she’s usually running trails or futzing with her garden.