Why do you still get muscle cramps despite taking magnesium?
Magnesium has no demonstrable effect on the most common nocturnal cramps, and with exercise-related cramps the cause likely lies elsewhere. If the cramps persist, discuss with your doctor whether there is another explanation.
Magnesium simply does not help with nocturnal cramps in older adults, as two independent Cochrane reviews based on multiple randomised trials make clear. The measured difference compared with a placebo was negligible: an average of 0.18 fewer cramps per week, a figure that is statistically indistinguishable from chance. If you take magnesium and still get cramps, that is therefore not surprising.
One important reason why magnesium may fail: the cause of your cramps may have nothing to do with magnesium deficiency. With cramps during or after exercise, a growing body of research points to a disruption in the nerve control of the muscle. The activating signals from the muscle dominate, while the inhibiting signals from the tendon weaken. That is a mechanism in which extra magnesium plays no role.
The popular theory that sweating leads to electrolyte loss and that this causes cramps is also on shaky ground. Four prospective cohort studies do not support this hypothesis. The evidence for it comes largely from anecdotes and small case reports totalling eighteen cases combined.
There is one more practical pitfall: are you also taking a proton pump inhibitor such as omeprazole or pantoprazole? Long-term use of these medications can lead to low magnesium levels in the blood, because absorption deteriorates. People who then take magnesium tablets may not be offsetting part of that problem. This is a known but by no means always recognised complication.
Finally, muscle cramps can also arise from muscular or neurological diseases, hormonal problems, or other metabolic disorders. If you have persistent or severe cramps that do not respond to stopping or adding magnesium, it is worthwhile discussing with your doctor whether there is another explanation.
Two Cochrane reviews (PMID 22972143 and 32956536) form the basis for the conclusion on nocturnal cramps. Reviews on exercise-related cramps (PMID 18981039, 29857264, 7830383) and classification of cramp types (PMID 12614310, 2178579) support the remaining points. The claim about proton pump inhibitors is based on one study not further indexed (PMID 21555654).