Can't sleep? Maybe it's something you ate—or didn't. "What we eat can seriously affect the amount and quality of our sleep," says Shari Lieberman, author of The Real Vitamin and Mineral Book (Avery, 2003). "Some foods stimulate the nervous system, while others calm and relax the body." Just a few small changes in your diet could put your sheep-counting habit to bed for good.

Drink a glass of warm milk
Grandma's favorite sleep remedy may work: Milk contains tryptophan, an amino acid that acts as a precursor to serotonin, which slows down nerve impulses and calms the brain when combined with carbohydrates (Revista de neurologia, 2005, vol. 40, no. 3). Food sources of tryptophan appear to be as effective as supplements; a recent study showed that tryptophan from protein, when eaten with carbs, significantly reduced insomnia and night waking (Nutritional Neuroscience, 2005, vol. 8, no. 2). In addition to milk, you can get tryptophan from cheese, yogurt, turkey, chicken, soy, seafood, beans, nuts, and seeds. When to eat for zzz's: about 45 minutes before bed. Menu ideas: turkey and vegetable stir-fry (see recipe below); chicken breast with braised spinach; strawberry and yogurt smoothie; high-fiber cereal and milk.

Cozy up with complex carbs
Carbohydrates increase serotonin levels by facilitating tryptophan's transport into the brain. Avoid starchy carbs, including rice, pasta, bread, and white potatoes, which can upset blood sugar and cause night waking. "Focus on low glycemic-index starches to keep blood sugar levels balanced," Lieberman says. Carbs that have the least blood-sugar impact include beans, lentils, nuts, seeds, sweet potatoes, winter squash, leafy green vegetables, citrus, apples, pears, and berries. When to eat for zzz's: two to three hours before bed. Menu ideas: baked winter squash with chopped walnuts; a small bowl of berries; bean soup; apple or pear slices with almond butter.

Calm down with magnesium
If you're stressed, taking calcium, or consuming lots of soda and other refined carbs, your body may be magnesium-deficient—all these things can deplete this vital nutrient. "Magnesium naturally relaxes the nerves and muscles, to calm the body and encourage sleep," says Hyla Cass, MD, author of Natural Highs (Avery, 2002). It also helps prevent nighttime leg cramps (Medical Science Monitor, 2002, vol. 8, no. 5). Get magnesium from leafy green vegetables, beans, soy, whole grains, and almonds. When to eat for zzz's: If you think you're not getting enough in your diet, consider taking a magnesium supplement—about 400 mg—half an hour before bed. Menu ideas: spinach salad with walnuts and shredded cheese; braised kale with tamari-roasted almonds; steamed Swiss chard and turkey strips; sautéed bok choy and chickpeas.

B sleepy
Your body needs vitamin B6 to produce serotonin, and it draws on vitamin B12 for a healthy nervous system, so deficiencies can lead to insomnia. Combining Bs with magnesium and calcium "creates a calming effect on the nervous system," says Rich O'Neill, CN, CPT, a Colorado-based fitness consultant. B6-rich foods include beans, whole grains, seafood, turkey, chicken, spinach, and nuts; animal products, such as dairy and eggs, provide the most B12. When to eat for zzz's: all day long, and especially a few hours before bed. Menu ideas: grilled shrimp; sprouted lentils; cheese and bean wrap (use lettuce instead of a tortilla); smoked salmon with low-fat cream cheese; hummus; baked tempeh cubes.

Look for patterns
If you toss and turn for several hours before dozing off but then sleep through the night, try a dinner of complex carbs with a little tryptophan-rich protein to encourage the brain's production of serotonin. Good options include black bean, sweet potato, and spinach soup (Click here for the recipe); or poached salmon with braised chard and winter squash.

If you fall asleep easily but then wake up four or five hours later, eat a bedtime snack. A high-protein nibble with a low-GI carbohydrate, such as nut butter spread on apple slices, or a hard-cooked egg with high-fiber crackers, can help steady blood sugar levels and release serotonin later in the night.

After researching this story, health and nutrition writer Lisa Turner now sleeps restfully through the night.