According to the NIH magnesium fact sheet, magnesium is safe provided you don't exceed the RDAs (including food sources and supplements), which vary based on your age and pregnancy or lactation status. To be sure, always check with your doctor.