When you are staring at the ceiling at 2 a.m., the over-the-counter aisle can feel like a promise and a puzzle. Two of the most common options you will see are melatonin and diphenhydramine (the antihistamine found in many “PM” products). They can both make you sleepy, but they do it in very different ways, and that difference matters for your symptoms, your next-day functioning, and your overall safety.
This guide is meant to help you choose the option that best matches why you are not sleeping, not to push a “best” product. If insomnia is becoming a pattern (most nights for a few weeks), think of OTC products as a short bridge while you look for the underlying cause.

The quick takeaway
- If your main issue is falling asleep (especially after a late night, travel, or a shifted schedule): melatonin often fits better.
- If your issue is short-term sleeplessness tied to nighttime allergy symptoms (runny nose, sneezing, itching) or a miserable cold with lots of runny nose: diphenhydramine may help, but next-day grogginess and other side effects are common.
- If you are waking up a lot, snoring loudly, gasping, or feeling unrefreshed most mornings: neither option treats the root cause. Consider evaluation for sleep apnea, restless legs, reflux, pain, anxiety, depression, medication effects, or other sleep disorders.
How they work
Melatonin
Melatonin is a hormone your brain naturally releases in the evening to signal “it is nighttime.” Think of it like a time cue for your body clock. Taking a small dose can help shift or reinforce your sleep timing, especially when your schedule is off.
Melatonin is not a sedative in the same way many sleep medicines are. Some people feel noticeably sleepy, but others mainly notice that they fall asleep more smoothly over several nights.
Diphenhydramine
Diphenhydramine is a first-generation antihistamine. It blocks histamine in the brain, and histamine is one of the chemicals that promotes wakefulness. That is why it can cause drowsiness. It is also anticholinergic, meaning it blocks acetylcholine, which is one reason it can cause dry mouth, constipation, urinary retention, and confusion in some people.
Diphenhydramine is closer to a “knock-you-drowsy” medication than melatonin, and the tradeoff is often more side effects.

Onset and duration
Melatonin timing
- Typical onset: often within about 30 to 60 minutes.
- Duration: varies by product. Immediate-release tends to be shorter, and extended-release can last longer through the night.
- Best for: sleep-onset difficulty and circadian rhythm misalignment (jet lag, shift work, delayed sleep phase).
Diphenhydramine timing
- Typical onset: often within about 30 minutes, sometimes sooner.
- Duration: longer and more likely to cause next-day drowsiness, because it can linger in your system.
- Best for: occasional insomnia when you also have nighttime allergy symptoms, and you have enough time for a full night of sleep.
Practical tip: If you have to be sharp early tomorrow, diphenhydramine is more likely than melatonin to leave you feeling “hungover” the next day.
Dosing and safe use
Important: Follow your product label and talk with a clinician or pharmacist if you have chronic conditions, take daily medications, are pregnant, or are buying for an older adult. The suggestions below reflect common clinical ranges, but individual needs vary.
Melatonin dosing
- Start low: many adults do well with 0.5 mg to 1 mg.
- Common range: 1 mg to 3 mg taken about 30 to 60 minutes before bedtime.
- Higher doses: some products offer 5 mg to 10 mg, but more is not always better. Higher doses can increase vivid dreams, morning grogginess, or headaches.
- If staying asleep is the problem: consider an extended-release melatonin product, but still start with a lower dose if possible.
- Quality note: melatonin is sold as a supplement, and the actual amount in the bottle can vary by brand. If possible, look for third-party tested products (for example, USP or NSF marks) and avoid mega-doses unless a clinician has a reason for them.
Diphenhydramine dosing
- Typical adult dose for sleep: 25 mg to 50 mg at bedtime. Many labels use 50 mg, but starting at 25 mg may reduce next-day grogginess.
- Do not stack products: many “PM” formulas already contain diphenhydramine. Taking a separate diphenhydramine tablet on top of a PM product is a common accidental overdose scenario.
- Also watch acetaminophen: some “PM” products combine diphenhydramine with acetaminophen (for example, Tylenol PM). If you also take a cold, flu, or pain product that contains acetaminophen, it is easy to take too much.
- Give yourself time: only take it when you can sleep a full night, since morning drowsiness is common.

Match the option to your symptoms
If you cannot fall asleep
- Melatonin often makes more sense when your sleep timing is off, such as after travel, late-night screen time, or a stretched schedule.
- Diphenhydramine can make you drowsy, but it does not correct your body clock. You may fall asleep faster, but the next day can feel foggy.
If you fall asleep but wake up a lot
- Extended-release melatonin may help some people with middle-of-the-night waking, particularly if the issue is light sleep rather than pain, reflux, hot flashes, or sleep apnea.
- Diphenhydramine is not a great “stay asleep” tool for many adults because it may lead to less restorative sleep for some people and it raises the risk of next-day impairment.
If allergies or a cold are keeping you up
- Diphenhydramine can help when itching, sneezing, or runny nose is keeping you up. That said, consider whether a non-drowsy daytime antihistamine or targeted allergy treatment would control symptoms without sedation.
- Melatonin will not treat allergy or cold symptoms, but it may still help with sleep-onset if your schedule is steady.
If insomnia has been going on for more than a few weeks, I encourage my patients to treat that as a health signal, not a personal failure. Short-term OTC help is one thing. Persistent insomnia deserves a deeper look.
Common side effects
Melatonin side effects
- Morning grogginess, especially with higher doses or extended-release formulas
- Headache
- Dizziness
- Nausea
- Vivid dreams or nightmares
Diphenhydramine side effects
- Next-day drowsiness, slowed reaction time, “brain fog”
- Dry mouth, dry eyes, constipation
- Urinary retention or difficulty urinating
- Blurred vision
- In some people, especially children or older adults: paradoxical agitation, confusion, or delirium
Safety note: If you drive, operate machinery, or make high-stakes decisions early in the morning, diphenhydramine is more likely to interfere than melatonin.
Interactions and higher-risk situations
Melatonin: key interactions and cautions
- Alcohol: can worsen sleep quality and increase sedation and next-day grogginess.
- Other sedating medications: additive drowsiness can occur.
- Blood thinners and antiplatelet medications: talk with your clinician. Some sources raise a possible bleeding interaction, but evidence is limited and mixed.
- Immunosuppressants: melatonin can influence immune signaling, so it is worth a clinician check-in if you are on immune-modulating therapy.
- Seizure disorders: discuss with your clinician before using regularly. Evidence is inconsistent, and the right advice depends on your specific seizure history and medications.
Diphenhydramine: key interactions and cautions
- Alcohol, opioids, benzodiazepines, cannabis, sleep medications: additive sedation and impaired coordination. The risk is higher if you have sleep apnea or significant lung disease, or if you combine multiple sedating substances.
- Other anticholinergic drugs: higher risk of confusion, constipation, urinary retention, and overheating. Many medications have anticholinergic properties, including some bladder medications and some antidepressants.
- MAO inhibitors: can intensify and prolong anticholinergic effects.
- Other products containing diphenhydramine: common in nighttime cold and flu medications. Double-dosing happens easily.
If you are unsure about interactions, a pharmacist can usually answer in minutes with your medication list.
Who should avoid or be cautious
Melatonin: avoid or use only with clinician guidance if you
- Are pregnant or breastfeeding (safety data is limited)
- Have an autoimmune condition or take immunosuppressive therapy
- Have epilepsy or a seizure disorder
- Take anticoagulants or antiplatelet medicines
- Have severe liver disease
Diphenhydramine: avoid or be extra cautious if you
- Are 65 or older, due to higher risk of confusion, falls, and memory issues from anticholinergic effects (it is also listed on the Beers Criteria as potentially inappropriate for many older adults)
- Have glaucoma (especially narrow-angle)
- Have benign prostatic hyperplasia (BPH) or trouble urinating
- Have chronic constipation or bowel obstruction risk
- Have asthma or COPD and are sensitive to sedating meds
- Have a job or schedule where next-day alertness is critical
Children: Do not give diphenhydramine as a sleep aid without a pediatric clinician’s guidance. In kids, it can cause agitation instead of sleepiness.
How long is too long?
As a general rule in primary care, I like OTC sleep aids to be a short bridge, not the plan.
- Diphenhydramine: best reserved for occasional use. Tolerance can develop, meaning it stops working, while side effects remain. Regular use is not recommended, particularly in older adults.
- Melatonin: may be used longer-term in some situations (like circadian rhythm issues), but it is still wise to re-check the “why” behind the insomnia if you are relying on it most nights.
If you need a sleep aid more than a couple of times a week for several weeks, it is worth talking with a clinician about underlying causes and non-medication approaches like CBT-I (cognitive behavioral therapy for insomnia), which has strong evidence and lasting benefits.
Sleep basics that help
OTC aids work best when your environment and habits are supporting sleep, not fighting it.
- Keep the wake time consistent, even after a bad night.
- Dim lights and screens for the last 60 minutes before bed. Blue light and bright overhead light tell your brain “daytime.”
- Limit alcohol close to bedtime. It may help you doze off but often worsens middle-of-the-night waking.
- Be cautious with late caffeine. Many people need to stop by early afternoon.
- Cool, dark bedroom and a wind-down routine (stretching, shower, reading).

When to call a clinician
Please consider medical follow-up sooner rather than later if you notice any of the following:
- Insomnia lasting more than 3 to 4 weeks
- Loud snoring, gasping, or witnessed pauses in breathing
- Severe daytime sleepiness or dozing off while driving
- Restless legs symptoms, frequent leg jerks, or a “creepy-crawly” feeling at night
- Depression, anxiety, or panic symptoms affecting sleep
- Using alcohol or other substances to sleep
- New confusion, falls, urinary retention, or severe constipation after starting diphenhydramine
FAQ
Can I take melatonin and diphenhydramine together?
It is generally not a good idea to combine them without clinician guidance. The sedation can add up, and diphenhydramine already carries a higher risk of next-day impairment. If one is not working, it is usually better to reassess the cause of the insomnia rather than stacking products.
Is melatonin safer than diphenhydramine?
For many adults, melatonin has a more favorable side-effect profile, especially regarding next-day fogginess and anticholinergic effects. But “safer” depends on your health history and medications. Pregnant or breastfeeding people, and people on certain medications, should check with a clinician first.
Why does diphenhydramine stop working after a few nights?
Your body can develop tolerance to the sedating effect, meaning you feel less sleepy even though the medication is still affecting your system and can still cause dry mouth, constipation, and grogginess.
What if I wake up at 3 a.m. and cannot fall back asleep?
Try to avoid taking diphenhydramine in the middle of the night because it can leave you sedated into the morning. For melatonin, middle-of-the-night dosing can also cause morning grogginess. Frequent 3 a.m. awakenings often point to an underlying issue like stress, alcohol effects, reflux, pain, or sleep apnea and those respond best to targeted treatment.
The bottom line
Melatonin is often the better fit when your sleep timing is off and you mainly need help falling asleep. Diphenhydramine can be useful for very occasional nights, especially when allergy symptoms are part of the problem, but it is more likely to cause next-day grogginess and has more medical cautions.
If sleep is a recurring struggle, you deserve more than a quick fix. A conversation with your clinician can uncover treatable causes and help you sleep better in a way that holds up long-term.