Stress is often seen as a culprit when you are unable to get a good night's sleep. But your diet also plays a role in it. Check your nutrient intake to sleep well. The following vitamins and minerals are required to solve sleep problems, reports huffingtonpost.com. * Magnesium: It plays a role in the bodily function that regulates sleep. Insomnia is one of the symptoms of lack of magnesium. A 2006 analysis in the journal Medical Hypothesis suggests that magnesium deficiency might be cause of depression and mental health problems. Dark leafy vegetables, pumpkin seeds, sesame seeds and beans are some of the food items rich in magnesium. * Potassium: A 1991 study in the journal Sleep revealed that supplements may be helpful to those who have trouble sleeping through the night. Beans, leafy vegetables and baked potatoes are some of the sources. * Vitamin D: A 2012 study in the Journal of Clinical Sleep Medicine found a strong correlation between excessive daytime sleepiness and vitamin D deficiency. The sun's rays are good for this vitamin. Some of the food sources include swordfish, salmon and tuna.