If you suffer the all too familiar midlife afflictions of insomnia, low mood or brain fog, there could be an unlikely culprit to blame: magnesium. Or rather, the lack of it. The deficiency is a hot topic from dinner parties to TikTok, where the hashtag #magnesium has received more than 1.3 billion views. “It’s one of the most common micronutrient insufficiencies in today’s diet,” says Rhian Stephenson, a nutrition therapist and the founder of the supplement and nutrition company Artah.

Why the fuss? “Magnesium is involved in over 600 bodily biochemical reactions,” ​​says Dr. Linia Patel, a dietician. “It is an essential dietary mineral that is involved in energy production, nervous system function, blood pressure regulation and blood glucose control. It also plays an important role in stress management and sleep.” Testing isn’t routine, so deficiencies often go undetected, but symptoms include mood changes, migraines and sleep disturbances, along with “general malaise,” according to Patel.

Magnesium has been shown to be hugely beneficial for brain health. One study published in The British Medical Journal followed more than 6,000 women over the age of 65 for more than 20 years and found a link between levels of magnesium and a lower risk of developing mild cognitive impairment. A separate study published in the journal Aging Neuroscience found magnesium improved cognitive function, while a 2017 review of 18 studies by psychology researchers found that magnesium could also reduce anxiety.

Heart health also appears to receive a dramatic boost with increased magnesium intake. After following nearly 90,000 nurses over 28 years, a study in the Journal of the American Heart Association found that those with the highest intake of magnesium (up to 349mg a day) had a 39 percent lower risk of having a heart attack compared with those with the lowest (less than 246mg a day). Another review of evidence found that those who had higher magnesium levels had an 8 percent lower chance of developing high blood pressure.

National guidelines say men need 300mg of magnesium a day, while women need 270mg. Yet according to the government’s UK National Diet and Nutrition Survey, Patel says, “about 20–25 percent of adult men and about 50 percent of adult women have magnesium intake below the recommended levels.”

This could be due to a multitude of reasons, but modern diets are often a root cause. “The typical diet is highly processed,” Stephenson says. “Studies have shown that certain micronutrient levels in ultra-processed diets don’t even reach half of the levels found in whole foods.” Magnesium is found in seeds and nuts, especially almonds, cashews and Brazil nuts.

But even those eating home-cooked meals could be affected if they use common processed ingredients, including white rice and flour. “Around 80 percent of magnesium is lost during food processing,” says Dr. Federica Amati, the head nutritionist at Zoe and the author of Every Body Should Know This. Added to that, intensive modern farming methods mean the amount of magnesium in the soil that fruits, vegetables and cereals are grown in has declined in the past 50 years.

“Midlifers are particularly vulnerable to low levels of magnesium,” Amati says. “There is some evidence that older adults consume less magnesium than younger people, and that they may not absorb or retain magnesium as effectively.”

Alcohol consumption further depletes magnesium, as does chronic stress, while some health conditions can exacerbate the problem. Lower magnesium levels have been reported in asthmatics, as well as migraine sufferers, while some medications, such as for high blood pressure, can affect absorption.

I wasn’t aware of my magnesium deficiency until I went for blood tests to get to the root of my chronic insomnia, something I’ve suffered from for most of my adult life. At the start of this year I was going through a particularly grim period, patching together three hours of broken sleep a night and feeling like a shell.

I went to HUM2N, a longevity clinic in London, for its Foundational Testing package (from $1,275), which tested 120 biomarkers and found healthy levels for most—except magnesium, which was chronically low.

Dr. Mohammed Enayat, an NHS GP and the clinic’s founder, warned me that thanks to my relatively healthy lifestyle (I cook most of my meals, eat lots of vegetables and exercise regularly), my body was managing to keep me going—for now. I was approaching 40, but if I left it much longer I could be in for serious health problems, including with my thyroid (magnesium is essential to thyroid hormone production). He recommended a 300mg nightly dose of magnesium, along with a gut-health diet (cutting out gluten, dairy and soy and increasing gut-boosting foods such as vegetables and seeds) to enable better absorption of the nutrients I was ingesting.

After a week or so of taking the supplements, my decades-long sleep problems were fixed. I was sleeping for a much more normal 7-8 hours a night. For me, it really was a wonder pill.

I’m not alone. Various studies, including one 2022 review of nine studies that collectively involved more than 7,500 people, have found that getting enough magnesium helps with sleep quality and quantity.

Some believe government recommendations for magnesium aren’t high enough. “Magnesium requirements are estimated based on body weight, and the current guidelines still use standard reference body weights that are lower than the actual mean body weights we see today, so it’s important to adjust,” Stephenson says.

In the US, the guidelines are higher at 420mg and 320mg for midlife men and women respectively, while studies have shown that higher doses can have a significant impact on our brains. Last year a study of more than 6,000 midlifers from UK Biobank, published in the European Journal of Nutrition, found that those who took over 550mg of magnesium daily—almost twice what women in the UK consume—were found to have a brain that was one year younger by the age of 55, compared with those consuming 350mg per day (a dose that is still higher than the UK recommendation).

Patel says whether the recommended dose should be raised for optimal health, rather than just to ward off disease, is “a good question and hard to answer.” She wants to see more research into specific population groups.

In the meantime, do we all need to start popping expensive supplements? Or can we up our magnesium naturally? Stephenson recommends greens, beans and nuts as good starting points. “One cup of cooked spinach, for example, has 158mg of magnesium; one cup of cooked black beans about 120mg; and one ounce of cashews about 80mg.” She adds that barley, quinoa, buckwheat, brown rice and oats are also good sources, as are avocados, fatty fish, natural peanut butter and whole food soy products, such as tofu and edamame. One square of dark chocolate (at least 70 percent) has nearly 65mg of magnesium.

But for some there is no doubt that supplements will help, especially if you are deficient. For example, a trial of post-menopausal women with osteoporosis showed that magnesium supplementation (250−750mg per day) for two years significantly improved bone density. Enayat advises testing and a personalized dose—higher levels can lead to unwelcome gastrointestinal issues in some—adding that almost everyone could benefit from upping their intake. “It’s a simple mineral that could be the missing raw ingredient to solve your symptoms.”

Jessica Salter is a London-based editor and writer