
If you find yourself tossing and turning at bedtime or staring at the ceiling at 3 a.m., you may be wondering if magnesium — often touted to promote relaxation and rest — might be the secret to a better night’s sleep.
It might be worth a try, particularly if you have a magnesium deficiency, says Denise M. Millstine, M.D., assistant professor of medicine and director of integrative medicine and health at Mayo Clinic in Arizona. People at greatest risk of magnesium deficiency include women, older adults, people who drink alcohol regularly, and those who have a diet high in convenience foods and processed foods.
Certain medications, including proton pump inhibitors and diuretics, can contribute to magnesium deficiency. These medicines may impair magnesium absorption or increase its loss through urine. Proton pump inhibitors are used to treat chronic acid reflux, also called gastroesophageal reflux disease (GERD). Diuretics, sometimes called water pills, are used to reduce fluid buildup in the body and are commonly used to treat high blood pressure.
How magnesium may help with sleep
Magnesium is a mineral that plays an important role in various body functions, including the balance of neurotransmitters — the chemical messengers your body uses to help nerve cells communicate with each other, Dr. Millstine says. These chemical messengers send signals between the brain and the rest of the body, playing a key role in mood, sleep, memory and muscle movement.
“Neurotransmitters can be excitatory or relaxing,” Dr. Millstine says. “Magnesium plays a role in helping maintain the right balance between the two types.” If anxiety or racing thoughts keep you from getting to sleep or wake you up, magnesium may shift the balance toward the relaxing set of neurotransmitters and help you sleep.
Dr. Millstine says people who have ” a busy brain” may benefit most. “Maybe they have anxiety that can be quieted or suppressed during the day, but at night, these thoughts become busy, louder and harder to ignore,” she says.
Magnesium also has a role in the production of melatonin, a natural hormone that helps regulate the body’s sleep-wake cycle. “Melatonin is important because it increases as the world darkens,” Dr. Millstine says. “It’s a signal in our system that it’s coming to be time to rest and to sleep.”
Magnesium may help people whose sleep is disrupted due to leg cramps or restless legs syndrome. “Somebody who doesn’t get good quality sleep because they are waking up with leg cramps or restless legs syndrome could try magnesium as long as it’s safe for them to take,” Dr. Millstine says.
How much magnesium can you take for sleep?
As long as you have healthy kidney function, magnesium supplements should be safe to take, says Dr. Millstine. She recommends 250 to 500 milligrams of magnesium in a single dose at bedtime. Although it is safe to take magnesium along with other sleep aids, it is unlikely to have any additional effect, she says.
What’s the best magnesium for sleep?
Although the most evidence supporting magnesium as a sleep aid is for a form called magnesium citrate, that form also has potent laxative effects, says Dr. Millstine. Unless you are prone to constipation, a form that is gentler on the intestinal system, such as magnesium glycinate, or is less expensive, such as magnesium oxide, might be better choices.
Does magnesium spray work for sleep?
Magnesium comes in a variety of forms, including tablets, capsules, powders and topical sprays. Dr. Millstine recommends supplements taken by mouth for better absorption. While some magnesium sprays have a calming scent that may help you relax, the amount of magnesium that’s absorbed through the skin is probably low. “I wouldn’t recommend topical magnesium, whether it’s a spray or a gel,” says Dr. Millstine. “I think the transdermal absorption of magnesium is quite low, or at the very least inefficient, so using magnesium as a spray isn’t recommended for sleep.”
Trying magnesium for sleep
Dr. Millstine recommends giving magnesium a try if you find it hard to fall asleep or stay asleep and are at risk of magnesium deficiency. “What I often do is have people take it nightly for three months and see if their ability to fall asleep or their ability to stay asleep has improved,” she says.
Some people find magnesium supplements to be a valuable part of a comprehensive approach to improving sleep. Incorporating it along with established sleep hygiene practices — such as keeping a consistent bedtime routine, limiting screen time before bed, reducing caffeine and alcohol intake, and creating a comfortable sleep environment — may enhance sleep quality and overall well-being.

Relevant reading
Mayo Clinic on Crohn’s Disease & Ulcerative Colitis
Gut health shortcuts and long-term whole-body research shed light on inflammatory bowel disease through every type of IBD, life phase, and related disease, including cancer. Reduce your symptoms and improve your quality of life by taking two expert Mayo Clinic doctors’ easy-to-digest advice.