provider image
Welcome! You’re in GoodRx for healthcare professionals. Now, you’ll enjoy a streamlined experience created specifically for healthcare professionals.
Skip to main content
HomeWell-beingSupplements and Herbs

Can Magnesium Help You Sleep Better?

Karen Hovav, MD, FAAPKatie E. Golden, MD
Updated on January 22, 2025

Key takeaways:

  • Studies suggest that magnesium may help you fall asleep faster, stay asleep longer, and wake up less overnight. 

  • There aren’t enough high-quality studies for magnesium to be recommended as a routine sleep aid. But for most people taking magnesium is low risk and doesn’t usually cause side effects. 

  • If you take magnesium for sleep, don’t forget to also focus on other ways to help you sleep better, too — like limiting caffeine, keeping the bedroom cool, and having a regular bedtime.

A person taking a supplement before going to bed.
MilanMarkovic/iStock via Getty Images Plus

Magnesium helps with many daily body processes. And sleep is one that gets a lot of attention. If you follow social media trends, you might be wondering if it’s the answer to all your sleep troubles. But what does the research say? We’ll take a deep dive into the science of magnesium and sleep to help you decide if magnesium is worth a try.

What is magnesium?

Magnesium is a nutrient our bodies need for:

  • Healthy muscles and nerves

  • Regulating blood pressure and blood sugar

  • Building strong bones, essential proteins, and DNA

Search and compare options

Search is powered by a third party. By clicking a topic in the advertisement above, you agree that you will visit a landing page with search results generated by a third party, and that your personal identifiers and engagement on this page and the landing page may be shared with such third party. GoodRx may receive compensation in relation to your search.

The daily recommended amount of magnesium for adults ranges from 310 mg to 420 mg. The good news is following a healthy diet that focuses on various nutrient-dense foods can help you get enough magnesium.

Common food sources of magnesium include:

  • Seeds and nuts: such as pumpkin seeds, almonds, and cashews

  • Grains: such as oatmeal, fortified cereals, and whole wheat bread

  • Beans and legumes: such as black beans, kidney beans, and edamame

  • Dairy: such as milk and plain yogurt

  • Fruit and vegetables: such as bananas, raisins, and avocado

  • Proteins: such as salmon, chicken breast, and beef

A healthcare professional may recommend a magnesium supplement in some cases, like to treat a magnesium deficiency. Most people don’t need a supplement to keep their magnesium level in a normal range. Still, some people take a supplement for one of its many reported benefits.

Is magnesium effective for sleep

In the past few years, magnesium has become a popular topic on social media as a possible sleep aid. Magnesium was even the star ingredient in a “sleepy girl mocktail” that went viral on TikTok. The claim is that magnesium can be added to tart cherry juice and seltzer to help people sleep.

The research on magnesium and sleep has been mixed. But the majority of studies show some benefit to taking magnesium. A review of eight studies found that people taking magnesium were more likely to report:

  • Better sleep quality overall

  • Less time to fall asleep

  • Fewer times waking up overnight

GoodRx icon

Those studies measured people’s perception about their sleep. But does that mean their sleep quality was actually better? 

In a 2024 study, researchers tried to measure this by having participants wear a medical device while sleeping. Participants took either magnesium or a placebo daily for 2 weeks, then switched to the other option for another 2 weeks. Researchers found that taking magnesium:

  • Increased deep sleep

  • Increased overall amount of sleep

  • Reduced the number of times people woke up overnight

Another similar study from 2024 found that magnesium not only helps sleep quality, but also improves daytime energy, daytime productivity, and alertness.

But the evidence isn’t settled yet. “The science on the use of magnesium to promote sleep quality and sleep duration has been mixed,” says Indira Gurubhagavatula, MD, MPH, associate professor at the University of Pennsylvania’s Perelman School of Medicine. These mixed results might have been because of differences in dosing, timing, or presence of chronic health conditions. Other studies that found benefits to taking magnesium to improve sleep are considered poor quality. More high-quality research is needed to know how and when to treat sleep problems with magnesium. 

Why does magnesium help you sleep? 

Magnesium plays an important role in helping your nerves and muscle function. Magnesium may help you sleep by:

  • Relaxing your nervous system: It activates GABA receptors, which calm your nervous system and make it easier to wind down in the evening.

  • Relaxing your muscles: Magnesium helps muscles relax so that you feel less tension as you’re trying to sleep. 

  • Regulating melatonin: Magnesium plays a role in making melatonin. Melatonin is a hormone that helps regulate your sleep-wake cycle. 

  • Lowering your cortisol: Studies have shown that taking magnesium can lower your stress hormone, cortisol. 

What do the experts say?

“Overall, magnesium is not something that is routinely prescribed by sleep doctors. Not because of side effects — though too much magnesium could certainly cause these. But rather because results aren't clear,” says Kenneth Lee, MD, Medical Director of the University of Chicago Sleep Center. This may change now that newer studies are suggesting magnesium may indeed help you sleep.

The American Academy of Sleep Medicine published guidelines on medications and supplements for sleep in 2017, and magnesium wasn’t discussed at all. But, in 2024, the European Society of Sleep Medicine published this statement: “Magnesium supplementation may be an effective nonpharmacological intervention to promote sleep and mood.”

Experts also emphasize the importance of finding out what’s causing insomnia. A sleep disorder — like sleep apnea, restless legs, or even narcolepsy — could be at play. Or, it could be due to lifestyle factors, such as nicotine, caffeine, or alcohol. Sleep problems could also be a symptom of a medical condition such as chronic pain, dementia, or depression.

“A full medical evaluation can help identify the root cause,” says Gurubhagavatula. “This is important, so people don’t miss potentially serious conditions, and get the appropriate treatment,”

How much magnesium should you take for sleep?

If you’re going to take a magnesium supplement, The Food and Nutrition Board (FNB) recommends taking 350 mg or less. It’s hard to know exactly how much magnesium you should take to help you sleep, since there aren’t official guidelines for magnesium and sleep. But studies in which magnesium was effective often used doses of at least 250 mg per day. 

Can magnesium cause side effects?

If you’re taking the recommended dosing of magnesium, you’re unlikely to have side effects. That’s because your kidneys can get rid of a little extra magnesium in the urine. But taking high doses of magnesium, above the recommended amount, can cause diarrhea, stomach pain, and cramping. And anyone with a history of kidney problems should check with their healthcare team before taking a magnesium supplement. 

Very large doses of magnesium from laxatives and antacids — which could contain more than 5,000 mg in a day — can cause serious symptoms of magnesium toxicity. These symptoms include:

  • Low blood pressure

  • Sleepiness

  • Vomiting

  • Muscle weakness

So, should I try magnesium?

It’s worth a try. Since magnesium has low risk for side effects, it’s safe to try out as a sleep remedy. To be sure you’re buying a safe and effective supplement, look for a third-party certification seal. 

And, remember, it’s still important to focus on healthy sleep habits. Even small changes — like avoiding electronics before bedtime or picking the right mattress — can make a big difference when it comes to sleep. Gurubhagavatula recommends:

  • Limiting caffeine and alcohol

  • Keeping a regular bedtime and wake-up time

  • Sleeping in a dark, cool, and quiet environment

Frequently asked questions

How long before bed should you take magnesium?

There’s no clear consensus on the exact timing of taking magnesium supplements. But, if you’re taking magnesium to help you sleep, you might find it more helpful to take in the evening. Taking it about an hour before bedtime should be enough time for its effects on your brain and muscles to kick in.

Which type of magnesium is best for sleep?

There are many different types of magnesium supplements. But it’s not clear which type works best for sleep. Studies on magnesium and sleep used different formulations, such as: 

  • Magnesium glycinate

  • Magnesium L-aspartate

  • Magnesium oxide

  • Magnesium lactate

Can magnesium help with anxiety?

Magnesium has been shown in some studies to help with anxiety. The results aren’t consistent, though. It seems to be more helpful for people with mild-to-moderate anxiety than severe anxiety. And a large review found that magnesium wasn’t helpful for people who were experiencing anxiety recently after having had a baby.

The bottom line

If you struggle with sleep, you might feel desperate for solutions. Magnesium is a popular option that may help. There’s evidence that it can help people fall asleep faster, stay asleep longer, and wake up less at night. It may not be quite the miracle cure that’s gone viral on social media, but it’s low risk and worth a try. For the best chance of success, make sure to focus on health sleep habits as well — like avoiding screens before bedtime, limiting caffeine and alcohol, and keeping your bedroom cool.

why trust our exports reliability shield

Why trust our experts?

Karen Hovav, MD, FAAP
Karen Hovav, MD, FAAP, has more than 15 years of experience as an attending pediatrician in a variety of clinical settings. She has worked in a large academic center in an urban city, a small community hospital, a private practice, and an urgent care clinic.
Katie E. Golden, MD
Katie E. Golden, MD, is a board-certified emergency medicine physician and a medical editor at GoodRx.

References

Andersen, S., et al. (2021). Does magnesium supplementation decrease anxiety in adults? Evidence-Based Practice

Arab, A., et al. (2023). The role of magnesium in sleep health: A systematic review of available literature. Biological Trace Element Research

GoodRx Health has strict sourcing policies and relies on primary sources such as medical organizations, governmental agencies, academic institutions, and peer-reviewed scientific journals. Learn more about how we ensure our content is accurate, thorough, and unbiased by reading our editorial guidelines.

Was this page helpful?

Habits for a Healthier Mind

Sign up for our GoodRx Mental Well-being Newsletter to receive up-to-date information on the latest medications, tips, and savings that are most relevant to you.

By signing up, I agree to GoodRx's Terms and Privacy Policy, and to receive marketing messages from GoodRx.