Keep your feet warm in bed. Bed socks & hot Water bottle, might help, according to.some people. Hope you can find a cure soon. It's miserable. I get it in my legs sometimes.
I agree,magnesium deficiency is bloody rare, HOWEVER, inadequate intake of magnesium although not uncommon is associated with chronic disease e,g Type 2 diabetes and alchoholism.......but still not that common.