Magnesium reduces the excitability of your brain and creates the right conditions for the release of melatonin. Plus, it can regulate the circadian rhythm and it lowers cortisol, which in the human body is known as the stress hormone, and it’s often responsible for keeping us awake. Have you ever had trouble sleeping before an important exam or a trip? That’s cortisol for you.