Many many people have a magnesium deficiency, which causes all sorts of issues. Supplementing magnesium can help with a lot of issues - help improve sleep quality, laxative, increased energy, reduces headaches... there is a long list of things that magnesium can improve if you are low on it.
Just make sure that the magnesium that you take is chelated (pronounced Kee-lated) as it can not really be assimilated by the body otherwise.
Yes! Magnesium! and drink plenty of fluids, too. I haven't had a headache in a really long time. A long time ago that I added magnesium to the vitamin line up, I don't think I've had a headache since.