Magnesium or melatonin for sleep: which is better, and can you take them together
Short answer: they help in different ways. Melatonin shifts your internal clock and works the same evening, when your schedule is off or after a flight. Magnesium covers a shortfall of the mineral, and your sleep may get better over a few weeks. You can take magnesium and melatonin together, but start with one.
MyGymGuid team · Updated November 23, 2026
Quick facts
- Schedule off, jet lag
- Melatonin 0.5–1 mg 30–60 minutes before bed
- Low magnesium in your diet
- Magnesium 100–250 mg a day, in the evening with dinner
- Together
- Fine, but start with one and see how you react
- Ashwagandha
- Small effect on sleep, and more safety questions
- Evidence
- Modest for both: fix your sleep routine first
How magnesium and melatonin differ
Both supplements sit on the "for sleep" shelf, but they work in completely different ways.
Melatonin is a hormone your body makes on its own when it gets dark. For your brain, it's the "it's night now" signal. The supplement adjusts your internal clock and slightly speeds up falling asleep. It's not a sleeping pill: if you're wound up or sitting in bright light, it may not work.
Magnesium is a mineral your muscles and nerves can't work without. It doesn't "switch on" sleep. If you don't get enough magnesium from food, a supplement makes up for it, and your sleep may improve. If you already get enough, don't expect a miracle.
| Melatonin | Magnesium | |
|---|---|---|
| What it is | Hormone, the "night" signal | Mineral from food |
| How it helps | Shifts your clock, speeds up sleep onset | Covers a shortfall |
| Effect | The same evening | After a few weeks |
| Dosage | 0.5–1 mg, 3 mg max | 100–250 mg from a supplement |
| When | 30–60 min before bed | With dinner or 1–2 h before bed |
| How long | Short periods | Fine every day |
Which is better for sleep: how to choose
First figure out why you sleep badly. What helps depends on the cause.
- Can't fall asleep before 2–3 a.m., schedule is off: melatonin. It helps move your sleep earlier.
- A flight across 5 or more time zones: melatonin. This is its most reliable use: in a Cochrane review, 9 out of 10 studies showed that it reduces jet lag.
- Low magnesium in your diet (a limited diet, cutting, sweating a lot in training): magnesium. Nuts, seeds, legumes and buckwheat provide it without a supplement.
- Lots of nerves, stress: neither is the main remedy. What helps is a regular routine, rest and less caffeine. Ashwagandha helps only a little here, and it has risks; more on that below.
- Insomnia for months: see a doctor. For chronic insomnia, the first recommendation isn't pills but cognitive behavioral therapy.
What the numbers say. In a meta-analysis of 19 studies, melatonin sped up falling asleep by 7 minutes on average and added about 8 minutes of sleep. In older adults with insomnia, magnesium sped up falling asleep by about 17 minutes, but there were only three studies and their quality is low. You can't compare these numbers directly: they studied different people. There are no head-to-head comparisons of magnesium and melatonin.
Can you take magnesium and melatonin together
Yes. There are no known interactions between them: melatonin is a hormone, magnesium is a mineral.
In a 2011 study, 43 older adults with insomnia took melatonin together with magnesium and zinc before bed for 8 weeks. Their sleep got better than on placebo. But the group was small, everyone was about 78 years old, and a blend of three substances doesn't show what exactly worked. This result can't be applied to young athletes.
So start with one supplement. After 1–2 weeks you'll know whether it helps. Then, if needed, add the second. That way you know what works and what doesn't.
How to take them: an evening plan
- Magnesium: 100–250 mg of elemental magnesium a day, with dinner or 1–2 hours before bed. Bisglycinate is gentler on the stomach, citrate is cheaper. Count the magnesium, not the weight of the salt on the label: "1000 mg citrate" contains about 110–160 mg of magnesium.
- Melatonin: 0.5–1 mg 30–60 minutes before bed. If it doesn't help within a week, you can go up to 3 mg. There's no point going above 5 mg: all that increases is morning grogginess.
- Melatonin in short periods: for the week of a flight, or a couple of weeks to shift your schedule. There's little data on the safety of taking it for months.
- After taking it, dim the lights and put your phone away. Bright light suppresses both your own melatonin and the melatonin you took.
And what works better than any supplement: go to bed and get up at the same time, skip coffee and pre-workout after lunch, and after an evening workout give yourself an hour to wind down: a shower, dim light, no screens.
What about ashwagandha vs magnesium?
Ashwagandha is also sold "for sleep and stress". There is a benefit, but it's small. In a meta-analysis of 5 studies, sleep improved slightly with it, more noticeably in people with insomnia, at 600 mg of extract a day and with use of 8 weeks or longer.
On the other hand, ashwagandha raises more safety questions than magnesium and melatonin. Rare but serious liver injury has been reported. It can raise thyroid hormones. It's not for use during pregnancy. Denmark banned its sale in 2023, and the German institute BfR advises caution.
- Low magnesium in your diet: magnesium. It's safer and cheaper.
- Want to try ashwagandha: root extract only, as an 8–12 week course, and not if you have liver or thyroid conditions.
- With melatonin, ashwagandha is fine, but the drowsiness may add up. Start them one at a time.
Myths about magnesium and melatonin
- "Melatonin is a sleeping pill." No. It doesn't knock you out; it tells your body it's time to sleep. If you're nervous or have had coffee, it may not work.
- "More is better." No. Low dosages of melatonin often work as well as 3–5 mg, and you feel better the next morning. With magnesium, too much causes loose stools: keep supplements to 250 mg a day.
- "Magnesium B6 is better for sleep." There's no clear evidence that B6 noticeably boosts magnesium — that doesn't mean there's no effect at all. In one study, magnesium with and without B6 helped almost equally.
- "You get hooked on melatonin." There's no data showing you get used to it the way you do with sleeping pills. But long-term use is poorly studied, so short periods are better.
- Don't drive after melatonin until you feel fully alert. For children, melatonin only with a doctor. Magnesium with kidney disease: only as prescribed by a doctor.
Myths and FAQ
Which is better: magnesium B6 or melatonin?
It depends on the cause. Schedule off or a recent flight: melatonin. Low magnesium in your diet: magnesium, and you don't need B6 with it. If you take magnesium with B6, add up all your B6 for the day: EFSA considers up to 12 mg safe for adults.
How long does it take to work?
Melatonin: 30–60 minutes, the same evening. Magnesium doesn't work from a single serving: your sleep may improve over a few weeks, once your stores are back to normal.
Can I take them every day?
Magnesium: yes, up to 250 mg from supplements and if your kidneys are healthy. Melatonin: better in short periods. If you can't fall asleep without it for more than a month, work out the cause with a doctor.
What to take after an evening workout if you can't sleep?
First cut out caffeine and pre-workout after lunch and give yourself an hour to wind down. If you still can't fall asleep, you can take 0.5–1 mg of melatonin 30–60 minutes before bed. Don't take it before a workout.
Does magnesium help with night cramps?
Probably not. A 2020 Cochrane review concluded that magnesium is unlikely to noticeably help older adults with frequent cramps. If you get cramps often, see a doctor.
Can I take them with creatine and protein?
Yes. Neither magnesium nor melatonin has known interactions with sports supplements.
Log your supplements in the app
Add your supplements with the dose and the app will remind you and log each dose. Free.
Based on publicly available sources. Reference information, not a substitute for medical advice. If you have a health condition, are pregnant or take medication, talk to your doctor.