Melatonin is the most purchased sleep supplement in the world. Magnesium is a close second. Most people who can't sleep have tried one or both - and many still aren't sleeping well, which raises an obvious question: what's actually going on, and which one should you be taking for your specific problem?
The answer requires understanding what each one actually does - because they are fundamentally different interventions addressing different parts of the sleep system. Using the wrong one for your problem is like taking a painkiller for an infection. It might dull things slightly, but it doesn't touch the cause.
Melatonin is a timing hormone - specifically, it's the signal your brain uses to communicate that it's dark outside and sleep time is approaching. It's produced by the pineal gland in response to darkness and suppressed by light, particularly blue wavelengths.
What melatonin does not do: it does not make you sleep. It does not increase sleep depth. It does not regulate cortisol. It does not activate GABA receptors. It is a biological clock signal, not a sleep-inducing agent. The distinction matters enormously.
Melatonin supplementation is genuinely effective for two specific problems: jet lag (resetting a disrupted circadian clock to a new time zone) and delayed sleep phase disorder (where someone's natural sleep timing is shifted much later than desired, e.g. naturally falling asleep at 2am and wanting to fall asleep at 10pm). For both of these, low-dose melatonin (0.5mg to 1mg) taken at the right time works well.
Pharmacy melatonin typically comes in 3mg to 10mg doses - 10 to 100 times more than the body naturally produces. At these doses, melatonin can cause next-day grogginess, disrupt the body's own melatonin production over time, and produce vivid or disturbing dreams. If melatonin leaves you feeling foggy in the morning, the dose is almost certainly too high.
Magnesium operates on the sleep system at a completely different level. It's not a timing signal - it's structural support for the biological mechanisms that allow sleep to occur and be maintained.
Two mechanisms are directly relevant to sleep quality:
GABA receptor activation. GABA is your brain's primary inhibitory neurotransmitter - the chemical that allows your nervous system to stop firing. Magnesium is a required cofactor for GABA-A receptor function. Without adequate magnesium, GABA receptors become less responsive, meaning the brain struggles to downregulate into sleep regardless of how tired the body is. This is the neurological mechanism behind lying awake with a racing mind.
HPA axis regulation and cortisol control. Magnesium acts as a brake on the hypothalamic-pituitary-adrenal axis - the system that produces cortisol. When magnesium stores are depleted, this brake weakens. Cortisol rises too sharply and too early in the night, pulling you out of deep sleep in the 2am to 4am window. This is the physiological mechanism behind the 3am wake-up pattern.
The decision tree is simpler than most people think.
This is a sleep-timing problem. Melatonin may genuinely help here - specifically low-dose (0.3mg to 1mg) taken 60 to 90 minutes before your target sleep time. This is the one use case where melatonin is well-supported. But check first whether the issue is simply too much bright light or screen use in the evening, which suppresses natural melatonin production. Fixing the light environment is more effective and has no dosing downsides.
Melatonin does nothing for this. The 3am wake-up is a cortisol event - the cortisol awakening response firing too early because of depleted magnesium and a weakened HPA brake. Melatonin has no mechanism for addressing cortisol. Magnesium taurate, taken 60 to 90 minutes before bed, addresses this directly. Full explanation in the pillar post on the cortisol connection.
This is a GABA problem. Magnesium bisglycinate is the most targeted intervention - it crosses the blood-brain barrier and directly supports GABA receptor function. Melatonin does not affect GABA activity.
Non-restorative sleep is predominantly a cortisol and deep sleep architecture problem. Magnesium's HPA regulatory effects improve deep slow-wave sleep over time. Melatonin does not improve sleep architecture beyond its timing effects.
Yes - they don't interfere with each other and they address different mechanisms. If you genuinely have both a sleep-timing problem and a cortisol-GABA maintenance problem, combining low-dose melatonin (0.3mg to 0.5mg) with magnesium bisglycinate-taurate covers both layers.
In practice, most people with the 3am wake pattern find magnesium alone is sufficient - the timing issue often resolves when the cortisol is regulated and GABA is functioning properly. Start with magnesium alone, evaluate after 21 days, and only add melatonin if you have a genuine sleep-onset timing issue remaining.
Melatonin became the default sleep supplement not because it's the best intervention for most sleep problems, but because it's easy to understand, easy to market, and has an immediately recognisable mechanism. "Sleep hormone" is a compelling label. The reality - that it only addresses timing and not the underlying physiology driving most chronic sleep problems - is harder to put on a bottle.
For most people with chronic middle-of-the-night waking, a racing mind at bedtime, or consistently unrefreshing sleep, melatonin was never the right tool. Understanding why allows you to make a more targeted decision about what actually addresses your specific pattern. The guide on why magnesium often hasn't worked covers the other side of this - why the right tool still fails when taken in the wrong form at the wrong time.
Short-term use (days to weeks) is generally well-tolerated. Long-term nightly use at high doses (3mg+) is less studied, and there is some evidence that consistent exogenous melatonin supplementation can reduce the brain's own melatonin production over time. The more significant issue is that most people taking melatonin nightly have a problem that melatonin doesn't address - so they're taking it indefinitely without ever fixing the cause. If you've been taking melatonin every night for months without meaningful improvement, the underlying problem is not a melatonin deficiency.
Almost always a dose issue. Standard pharmacy melatonin is 5mg to 10mg - 15 to 30 times more than the body naturally produces at its peak. The excess melatonin extends into the morning, producing the "melatonin hangover" feeling. Try dropping to 0.5mg or 1mg (many health food stores stock these lower doses; they are not less effective for sleep timing - they are often more effective). If next-day grogginess persists at 0.5mg, melatonin may simply not be the right intervention for your pattern.
No - and this is important to understand before starting. Melatonin acts acutely, within an hour of taking it. Magnesium works by gradually rebuilding cellular stores that have been depleted over months or years. The first meaningful changes in sleep - quieter mind at bedtime, less intense 3am waking - typically appear around days 8 to 14. Full effect is usually by day 21 to 30. People who expect an overnight result stop within a week, right when the process is just beginning. The slow timeline is not a sign it isn't working.
Indirectly. Magnesium won't reset your circadian clock the way melatonin does, but it reduces the stress response that makes jet lag worse, supports GABA-mediated sleep in the new time zone, and reduces muscle tension and restlessness. For long-haul travel, combining low-dose melatonin (to shift timing) with magnesium bisglycinate (to support sleep quality in the new zone) covers both mechanisms. Magnesium alone won't fix jet lag; melatonin alone won't give you quality sleep in a disrupted state.
This is a question for a paediatrician, not a supplement guide. The short version: melatonin use in children is controversial, largely because melatonin plays a role in reproductive development and the long-term effects of supplementation during childhood are not well studied. Most childhood sleep problems are behavioural rather than physiological, and the evidence base for melatonin in typically developing children is limited. A GP or paediatric sleep specialist is the right starting point.