Experts Explain Why You Might Experience an Uptick in Nightmares While Taking Melatonin 91 Shares If you've ever had trouble falling asleep at night, chances are someone has recommended that you try melatonin. This over-the-counter supplement can help regulate your sleep-wake cycle when taken about an hour before bed. But while melatonin is popular, it could also have some unintended side effects — and experts generally agree that it isn't a long-term solution to your sleep problems. One of the more surprising side effects of taking melatonin? Nightmares. Here's why they happen — and what you can do to get a more peaceful night's sleep.