Patients who are dealing with chronic headaches, or headaches that seem to appear as soon as they wake up, could be suffering with a sleep disorder, Nancy Foldvary-Schaefer, DO, sleep medicine physician, tells the Cleveland Clinic’s health blog.

Headaches and slumber troubles are linked in a variety of ways. Being sleep deprived can make you more likely to develop a tension headache during the day. It’s often a vicious cycle, Dr. Foldvary-Schaefer explains. “Insomnia can cause tension headaches, which can make it harder to sleep, which can lead to more headaches.”

Lack of shuteye can also turn up the volume on other types of headaches. “When people aren’t sleeping well, their pain is magnified,” Dr. Foldvary-Schaefer says.

And even if you’re well-rested, sleep isn’t always an escape from chronic headaches. Both migraines and cluster headaches can come on while you’re snoozing. Of course, they can also strike when you’re wide awake, and the sun is shining.