Magnesium is an essential mineral that our bodies need to function properly. It can improve bone health, stabilize blood pressure, and help maintain a healthy heart rhythm and nerve function. Symptoms of being low in magnesium include fatigue, loss of appetite, nausea, muscle cramping, tingling, and muscle contractions.

Low magnesium is also linked to headaches and migraines. It’s estimated that many people don’t get enough magnesium through their diets. One study found that about 75 percent of Americans aren’t getting enough magnesium. Magnesium, and particularly magnesium oxide, is sometimes used to treat and prevent migraines.

There are multiple types of magnesium, which are sometimes used to treat different conditions. Magnesium isn’t easily absorbed by the body without being bound to another substance. Because of this, supplements often have magnesium combined with other substances, like amino acids.

The most common types of magnesium used in supplements include:

  • magnesium oxide, which can contain high levels of magnesium and is often used to treat migraines
  • magnesium sulfate, which is an inorganic form of magnesium, and only small amounts of the supplement can be absorbed into the body
  • magnesium carbonate, which has slightly higher levels of magnesium and is more likely to cause gastrointestinal upset
  • magnesium chloride, which is easily absorbed into the body
  • magnesium citrate, of which large amounts can be absorbed into the body; it is often used to induce bowel movements

Significant research has shown that people with migraines often have lower levels of magnesium than those without them. One study actually found that regular intake of magnesium reduced the frequency of migraine attacks by 41.6 percent. Other research has shown that taking daily magnesium supplements can be effective at preventing menstrual-related migraines.

Magnesium oxide is most frequently used to prevent migraines. You can take it in pill form, with a general recommended dosage of about 400 to 500 milligrams a day. Magnesium can be administered intravenously in the form of magnesium sulfate.

Because magnesium is a natural element and is necessary for our health, it may be a safe migraine treatment. This is especially true when compared to migraine medications, which can come with more severe side effects.

Magnesium is generally considered safe to take for most people, but taking it can result in some side effects. The most common side effects are abdominal cramping, vomiting, and diarrhea. If you experience these, you can try lowering your dosage for relief.

Another common side effect of magnesium is lowered blood pressure. If you already have low blood pressure, talk to your doctor before taking magnesium regularly.

Taking too much magnesium can lead to a dangerous buildup, and can result in serious side effects, such as:

  • irregular heartbeat
  • unsafe low blood pressure
  • slowed breathing
  • coma

For this reason, talk to your doctor before you start taking magnesium to ask about the best dosage for you.

For those who don’t want to take supplements, some foods naturally contain magnesium.

Dark leafy greens like spinach and chard are some of the best foods you can eat. One cup of either contains between 38 to 40 percent of the recommended daily value of magnesium.

Other foods that contain magnesium include:

  • seeds, like pumpkin or squash seeds
  • almonds
  • mackerel, tuna, and Pollock fish
  • low-fat yogurt or kefir
  • black beans and lentils
  • avocado
  • figs
  • bananas
  • dark chocolate

While supplements can provide a powerful boost, it’s best to focus on getting magnesium through your diet by incorporating magnesium-dense foods.

Certain people should not take magnesium, especially those with pre-existing medical conditions. This includes those who have:

  • bleeding disorders, as it can slow blood clotting
  • diabetes, as poorly controlled diabetes can affect how magnesium is stored in the body
  • heart block
  • kidney problems, including kidney failure

If you have digestive conditions like inflammatory bowel disease or a stomach infection, ask your doctor before taking magnesium. These conditions can affect how much magnesium the body absorbs.

Magnesium can also interact with other medications, including:

  • antibiotics
  • diuretics or water pills
  • muscle relaxants
  • heart medications

If you are pregnant, consult your doctor before you take magnesium. For pregnant women, it’s considered generally safe to take 350 to 400 milligrams of magnesium oxide in pill form each day. It is not safe to take magnesium sulfate intravenously, as that is associated with bone thinning in the fetus.

When taken in safe doses, magnesium can effectively prevent migraines for many people. Since magnesium generally has fewer side effects than prescription migraine medicine, it may be a more suitable option.

If you’re experiencing migraines for the first time, or they’ve increased in severity or frequency, seek help from your doctor. They can help you determine how much magnesium you should take and what other treatment options to consider.