Magnesium CAN help you sleep.
More Info: Magnesium is not a sleep aid nor does it promote drowsiness, but if your body is lacking adequate levels of magnesium, your sleepless nights may be resolved with increased magnesium intake.
Sleepless Nights? Magnesium Deficiency May Be to Blame
Sleep disturbances and insomnia are caused by a variety of factors including a magnesium deficiency. Research has indicated that magnesium plays an important role in the sleep process and that those with a deficiency demonstrate a significant increase in wakefulness, light and disorganized sleep, and have a harder time falling asleep with lower sleep quality. In several studies, sleep patterns returned to normal when magnesium levels were balanced. 
Magnesium Supplements as a Sleep Aid
Though increasing your magnesium intake may be the resolution to your sleep problems, taking supplements is probably not a good idea unless specifically recommended by your physician.
The caveat to using pharmacological magnesium whether in supplements or other forms is that is carries with it the risk of side effects if taken in excess. Side effects can include upset stomach, nausea, vomiting, and diarrhea. More serious side effects of extreme doses can include low blood pressure, irregular heartbeat, slowed breathing, confusion, and even coma and death. 
Magnesium supplements can also interact with other medications such as aminoglycoside antibiotics, quinolone antibiotics, tetracycline antibiotics, bisphosphonates, medications for high blood pressure, muscle relaxants, and water pills. 
Eat More Spinach-Sleep Better at Night
If your sleep issues are connected to low levels of magnesium, the best way to resolve the deficiency is through diet. In light of the fact that nearly 75% of Americans do not get enough magnesium in their diets, a logical, healthy first line of defense against those sleepless nights might be the increase of your dietary intake of magnesium.  You can easily increase your dietary levels of magnesium by eating a varied diet that includes plenty of legumes, nuts, whole grains, and vegetables. A few foods that are high in magnesium are wheat bran, almonds, spinach, raison bran, and cashews. 
And unlike pharmacological magnesium, the great thing about eating more magnesium rich foods is that there are no side effects.
Milk as a Sleep Aid?
As science has evolved over the decades many folk-remedies passed down through the generations have been proven ineffective. The traditional notion that warm milk before bedtime will help promote sleep may actually be valid. Milk contains 37 mg of magnesium, but also packs tryptophan, which the body uses to produce serotonin, a chemical in the body believed to be associated with sleep. 
 Neuropsychobiology; Depoortere H
Effects of Magnesium-deficient Diet on Sleep Organization in Rats
1993; Volume: 27; No: 4; Pages: 237-245
 Alcoholism, Clinical and Experimental Research; Hornyak M
Magnesium Treatment of Primary Alcohol-Dependent Patients During Subacute withdrawal: an Open Pilot Study with Polysomnography
2004; Volume: 28; No: 11, Pages: 1702-1709
Magnesium Side Effects & Safety
 American Family Physician; MARY P. GUERRERA
Therapeutic Uses of Magnesium
2009; Volume: 80; No: 2; Pages: 157-162
 Office of Dietary Supplements-National Institutes of Health
Glossary of Terms
Pharmacological: The science of drugs, including their composition, uses, and effects.
Serotonin: acts as a neurotransmitter, a type of chemical that helps relay signals from one area of the brain to another.
Tryptophan: The body uses tryptophan to help make niacin and serotonin. Serotonin is thought to produce healthy sleep and a stable mood.
“I find it very funny that more doctors aren’t clued in to the benefits of magnesium, because we use it all the time in conventional medicine. But we never stop to think about why or how important it is to our general health or why it helps our bodies function better.”