You wake up in the middle of the night and your heart is racing, pounding out of your chest. You’ve been falling or were being chased or someone you love is dying.

Though we know that nightmares aren’t real, it doesn’t change the fact that they’re terrifying. So why do they happen?

“There are a number of cases where having a nightmare might not seem unusual,” says Alesandra Woolley, Mattress Advisor’s Executive Editor and Certified Sleep Science Coach. “For instance, if you watch a horror movie and wake up from a bad dream that night, you may not be surprised.”

However, there are other scenarios that can lead to nightmares that may not be so obvious. Below, experts discuss five surprising reasons behind your nightmares.

1. Nighttime eating habits

It’s common for people to snack before bedtime. However, your nighttime eating habits could be darkening your dreams.

“If you find yourself having strange nightmares, you might want to try eating earlier in the night or reevaluating your late-night snacking habits,” Woolley suggests.

According to the sleep coach, eating too close to bedtime can trigger your brain to be more active while you sleep. “This means you have a higher chance of dreaming, or having nightmares, and remembering the details more vividly,” she says.

2. Drinking alcohol before bed

Contrary to popular belief, indulging in a nightcap does not help you sleep better. In fact, according to Woolley, it can lead to poor, interrupted sleep where your body never truly has a chance to recover and rejuvenate.

“[Alcohol] not only increases your chances of having vivid nightmares, but also can cause parasomnias such as sleepwalking or night terrors,” Woolley tells us.

3. Trying a new medication or supplement

“Certain medications can have an impact on brain activity and increase feelings of restlessness or anxiety at night,” says Woolley. “These side effects can cause you to have nightmares in certain cases.”

If you’ve recently started a new medication and are noticing a correlation with your frequency of nightmares, talk to your doctor about alternative options.

4. Chronic stress

“One of the primary triggers of nightmares is the presence of chronic stress and anxiety, particularly during times of life transitions,” says Haley Neidich LCSW LLC.

According to Neidich, many individuals who deal with stress and anxiety will report that when they are triggered (ie. their symptoms are increased due to a life circumstance) that they experience an increase in sleep disturbance, especially bad dreams. 

5. Lack of sleep

Though it might seem ironic, your sleeping patterns (or lack thereof) can contribute to your bad dreams. According to Mayo Clinic, sleep deprivation can increase your risk of having nightmares.

If you’re having trouble falling or staying asleep, try these tips for getting more sleep.