Researchers followed Puerto Rican adults for about 6 years to see if magnesium—a mineral found in foods like nuts and leafy greens—could help with sleep problems and depression. They found that people without diabetes who ate more magnesium-rich foods or took magnesium supplements had fewer sleep problems. Interestingly, this benefit didn’t appear in people with diabetes. The study didn’t find a strong connection between magnesium and depression symptoms. These findings suggest that magnesium’s effect on sleep might work differently depending on whether someone has diabetes.

The Quick Take

  • What they studied: Whether eating or taking magnesium helps people sleep better and feel less depressed, and whether having diabetes changes how magnesium works in the body.
  • Who participated: 1,465 Puerto Rican adults who were tracked over about 6 years. Researchers measured their magnesium intake from food and supplements, checked their blood magnesium levels, and asked about sleep problems and depression symptoms.
  • Key finding: Adults without diabetes who ate more magnesium-rich foods or took magnesium supplements had about 60% fewer sleep problems. This benefit disappeared in people with diabetes. Magnesium didn’t seem to help with depression symptoms in either group.
  • What it means for you: If you don’t have diabetes and struggle with sleep, eating more magnesium-rich foods (like almonds, spinach, or pumpkin seeds) might help. However, if you have diabetes, magnesium supplements may not provide the same sleep benefits. Talk to your doctor before starting any supplement, especially if you take diabetes medications.

The Research Details

This was a long-term follow-up study where researchers tracked the same group of people over about 6 years. They collected information about what people ate, measured magnesium levels in their blood, and asked them questions about sleep quality and depression at different time points. The researchers used statistical methods to look for patterns—specifically, whether magnesium levels predicted who would develop sleep problems later on.

The study was designed to test whether magnesium’s effects on sleep and mood might be different for people with and without diabetes. This is important because diabetes affects how the body processes minerals and regulates sleep. The researchers carefully adjusted their analysis to account for other factors that might affect sleep, like age, sex, and calcium intake.

This research approach is valuable because it follows real people over time rather than just looking at a single moment. This allows researchers to see whether magnesium levels actually predict future sleep problems, not just whether they’re associated with current problems. By examining whether diabetes changes magnesium’s effects, the study reveals that one-size-fits-all recommendations might not work for everyone.

This study has several strengths: it included a large number of participants (1,465), followed them for years, and measured both dietary magnesium and blood magnesium levels. However, the study focused only on Puerto Rican adults, so results might not apply equally to other populations. The researchers also relied on people remembering what they ate, which can be inaccurate. The study is observational, meaning it shows associations but cannot prove that magnesium directly causes better sleep.

What the Results Show

The main finding was that magnesium’s effect on sleep depends on diabetes status. In people without diabetes, eating more magnesium-rich foods was strongly linked to fewer sleep problems. Specifically, for every 100 milligrams of additional magnesium from food per day, the odds of having insomnia dropped by about 59%. People without diabetes who took magnesium supplements had even better results—about 63% lower odds of sleep problems.

However, this protective effect completely disappeared in people with diabetes. Those with diabetes showed no improvement in sleep problems whether they ate more magnesium or took supplements. This suggests that diabetes fundamentally changes how magnesium affects sleep in the body.

Regarding depression, the results were less clear. Higher magnesium intake was linked to slightly better mood (specifically, less difficulty experiencing positive emotions), but this was a small effect. Magnesium didn’t help with other depression symptoms. Blood magnesium levels showed no connection to either sleep or depression in any group.

The researchers found that the calcium-to-magnesium ratio in people’s diets didn’t significantly change the results. Sex (male or female) also didn’t appear to modify magnesium’s effects. The study suggests that the type of magnesium measurement matters—dietary magnesium showed benefits, but blood magnesium levels did not, which indicates that what you eat may be more important than circulating magnesium levels for sleep.

Previous research on magnesium and sleep has been mixed, with some studies showing benefits and others showing none. This study helps explain why: the effect appears to depend on whether someone has diabetes. The finding that magnesium doesn’t strongly affect depression aligns with some recent research questioning magnesium’s role in mood disorders. The study adds important nuance by showing that diabetes is a critical factor that previous research may have overlooked.

The study only included Puerto Rican adults, so findings may not apply to other ethnic groups or populations. Researchers relied on food frequency questionnaires, which depend on people accurately remembering what they ate—this can introduce errors. The study is observational, so it cannot prove that magnesium causes better sleep; other unmeasured factors could explain the connection. The sample size for insomnia analysis was smaller (613 people), which reduces statistical power. Finally, the study didn’t measure other factors that affect sleep, like stress levels or sleep apnea.

The Bottom Line

For people without diabetes who have sleep problems: Consider increasing magnesium-rich foods like almonds, pumpkin seeds, spinach, and dark chocolate. If dietary changes don’t help, magnesium supplements may be worth discussing with your doctor (typical doses range from 200-400 mg daily). For people with diabetes: This study suggests magnesium supplements may not help with sleep problems, though eating magnesium-rich foods remains part of a healthy diet. For depression: Magnesium alone is unlikely to be an effective treatment; professional mental health support is recommended. Confidence level: Moderate for non-diabetic sleep benefits; Low for depression benefits.

This research is most relevant to Puerto Rican adults and possibly other Hispanic populations, though findings may apply more broadly. People without diabetes who struggle with insomnia might benefit from trying magnesium-rich foods. People with diabetes should not expect magnesium supplements to solve sleep problems based on this research. Anyone taking diabetes medications should consult their doctor before starting magnesium supplements, as there may be interactions.

If magnesium helps your sleep, you might notice improvements within 2-4 weeks of consistent dietary changes or supplementation. However, sleep problems often have multiple causes, so magnesium alone may not completely solve insomnia. Give dietary changes at least 4-6 weeks before deciding whether they’re working.

Want to Apply This Research?

  • Track daily magnesium intake (target: 300-400 mg for adults) alongside sleep quality ratings (1-10 scale) and hours slept. Log magnesium sources: food vs. supplements. Note any diabetes diagnosis status to personalize recommendations.
  • Add one magnesium-rich food to your daily routine: sprinkle pumpkin seeds on salads, add spinach to smoothies, or eat a small handful of almonds as a snack. If you don’t have diabetes and sleep is poor after 4 weeks, discuss magnesium supplements with your doctor.
  • Weekly review of sleep quality trends correlated with magnesium intake. Create a simple chart showing: days with adequate magnesium intake vs. sleep quality ratings. If you have diabetes, track whether magnesium changes affect your sleep (likely won’t, but individual responses vary). Share data with your healthcare provider at annual checkups.

This research shows associations between magnesium and sleep in people without diabetes, but does not prove magnesium causes better sleep. Results may not apply to all populations. If you have diabetes, sleep disorders, or take medications, consult your healthcare provider before starting magnesium supplements, as they may interact with medications or affect blood sugar control. This information is not a substitute for professional medical advice. Anyone experiencing persistent insomnia or depression should seek evaluation from a healthcare provider.

This research translation is published by Gram Research, the science division of Gram, an AI-powered nutrition tracking app.

Source: Diabetes modifies the association between magnesium and insomnia, but not depressive symptomatology, in Puerto Rican adults: A prospective cohort study.The American journal of clinical nutrition (2026). PubMed 41862003 | DOI