At 44, hormonal shifts from perimenopause are a common cause of exactly this pattern: falling asleep but waking repeatedly through the early morning hours. It isn't something to panic about, but magnesium alone rarely fixes sleep disruption that's hormone-driven.
Next Steps
A gynaecologist can check where you are in the perimenopause transition and discuss sleep options that don't carry the headache side effects you get from antidepressants. Keeping a fixed wake-up time and cutting late caffeine and screens also helps.
Health Tips
If the sleeplessness keeps worsening or starts affecting your mood and daily functioning, please see a gynaecologist or your psychiatrist again soon.