Maybe, but the evidence is thin. The US National Center for Complementary and Integrative Health (NCCIH) says there is very little research on magnesium for insomnia, and that there is not enough strong evidence to say melatonin works or is safe for chronic insomnia. The NHS says you should be able to get all the magnesium you need from a varied and balanced diet, and that more than 400mg a day from supplements for a short time can cause diarrhoea. This is general information, not medical advice. Ask a doctor or pharmacist before you start a supplement.
Does magnesium help you sleep?
NCCIH’s page on sleep disorders says: “There is very little research on magnesium for insomnia.” It mentions a 2021 review of three studies that suggested magnesium “may help with sleep-onset latency,” which means how long it takes to fall asleep. The reviewers judged those studies to be low quality (NCCIH, Sleep Disorders: What You Need To Know, last updated May 2024).
So the honest answer is that nobody can promise it works. It is not proven not to work either. There just is not much good research.
If you want to know how much magnesium you need anyway, the NHS says adults aged 19 to 64 need 300mg a day for men and 270mg a day for women. It says you should be able to get all you need from a varied and balanced diet, with spinach, nuts and wholemeal bread as examples. About supplements it says: “If you take magnesium supplements, do not take too much as this could be harmful.” Having 400mg or less a day from supplements is unlikely to cause harm, and taking more than 400mg for a short time can cause diarrhoea (NHS, Vitamins and minerals, last reviewed 3 August 2020). The NHS also says there is not enough evidence on high doses taken for a long time.
Does melatonin help you sleep?
NCCIH says the evidence is mixed. Melatonin “may be helpful for sleep problems caused by shift work or jet lag.” For insomnia it says melatonin “may help” with how quickly people fall asleep, but two clinical practice guidelines “recommended against using melatonin for treating chronic insomnia.” It adds that melatonin “appears to be relatively safe for short-term use, but its long-term safety has not been established” (same NCCIH page).
A second NCCIH page on melatonin says there is “not enough strong evidence on the effectiveness or safety of melatonin supplementation for chronic insomnia.” In short-term studies only mild side effects were reported, such as headache, dizziness, nausea and sleepiness. It says melatonin can interact with some medicines, especially for people with epilepsy or on blood thinners (NCCIH, Melatonin: What You Need To Know, last updated May 2024).
What should you know about the label?
NCCIH warns that “some melatonin supplements may not contain what’s listed on the product label.” It cites a 2023 study in which 22 of 25 over-the-counter melatonin gummies were mislabelled, and a 2017 study in which most of 31 supplements did not match their labels. I would not trust a number on the front of a bottle without a pharmacist’s advice.
How does the NHS treat melatonin?
In the UK, the NHS lists melatonin as a medicine for sleep problems such as insomnia. Its page says most adults aged 55 or over can take it for short-term sleep problems. Adults under 55 and children with longer-term sleep problems can take it if a specialist recommends it. The NHS says to tell your doctor or pharmacist first if you have had an allergic reaction to melatonin, have liver or kidney problems, or have an autoimmune condition such as rheumatoid arthritis, multiple sclerosis or lupus (NHS, Who can and cannot take melatonin, last reviewed 13 February 2023).
It also says melatonin “should only be taken for a maximum of 13 weeks to treat short-term sleep problems in adults,” and to follow the instructions from a pharmacist or doctor (NHS, How and when to take melatonin, last reviewed 13 February 2023). Those pages describe the medicine the NHS provides, and what you buy in a shop or online may be a different product. A pharmacist can tell you which you have.
When should you see a doctor?
The NHS says to see a GP if changing your sleeping habits has not helped, if you have had trouble sleeping for months, or if insomnia makes daily life hard to cope with (NHS, Insomnia, last reviewed 19 March 2024). NCCIH says to talk with a health care provider before using melatonin if you take medicine, are pregnant or nursing, or have cancer. It also says it is best to work with a provider if you are thinking about melatonin for a child.
I am not a doctor, and nothing here is medical advice.
What can you try first?
Habits come first. A fixed wake-up time, morning light and a dark, cool bedroom are covered in can you learn to be a morning person. How much sleep do adults need shows what counts as a sleep problem. If you are thinking about prescription pills, read sleeping pills for insomnia: think again first. If the real problem is waking in the night, see why do I wake up at 3am. If a drink or cannabis is part of your routine, read do alcohol or cannabis help you sleep.
Want more?
The book has 74 tips for better sleep health, and the free cheat sheet gives you the short version.
Easy Sleep Solutions: 74 Best Tips for Better Sleep Health
Get the free Easy Sleep Solutions cheat sheet
Frequently asked questions
Does magnesium help you sleep?
NCCIH says there is very little research on magnesium for insomnia. A 2021 review of three studies suggested it may help you fall asleep, but the reviewers judged those studies to be low quality.
Does melatonin help you sleep?
NCCIH says the evidence is mixed. It may be helpful for shift work or jet lag, but there is not enough strong evidence on its effectiveness or safety for chronic insomnia.
Can melatonin supplements be mislabelled?
NCCIH warns that some melatonin supplements may not contain what is listed on the label. It cites a 2023 study in which 22 of 25 over-the-counter melatonin gummies were mislabelled.
Can too much magnesium cause problems?
The NHS says taking more than 400mg a day from supplements for a short time can cause diarrhoea. It says not to take too much, as this could be harmful.
Should I ask a doctor before taking either?
Yes. Ask a doctor or pharmacist before you start a supplement, especially if you take other medicines, because NCCIH says melatonin can interact with some of them.

