It's no secret that some foods can leave you tossing and turning at night. But do you know which foods to avoid and for how long before bed?

"The bottom line is that we know sleep is important," said sleep medicine Dr. Carmela Kiraly. 

Not getting enough sleep can leave your body feeling depleted and could even have long term impacts on your blood sugar, blood pressure, and more. 

But what you're eating could leave you wide awake

"The biggest one that most people are aware of is caffeine. I think one of the things that people aren't aware of is how many things caffeine can hide in," said Dr. Kiraly. "A few ounces of dark chocolate can have as much caffeine as a half a cup of coffee. Depending on the strength of the dark chocolate. And it's also in a lot of teas. Especially green or black tea, then you can build up quite a bit of caffeine."

"So if somebody is having trouble falling asleep at the beginning of the night, or staying asleep, that would qualify as insomnia. It's really best to avoid caffeine after two in the afternoon. Even earlier if possible, even noon is, even better," she explained. 

While some people like to think of a nightcap as a good way to fall asleep, Dr. Kiraly said that while alcohol can help you fall asleep immediately, it does more damage later in the night. 

"As the alcohol metabolizes in their system that will keep them awake, and so they might actually find themselves waking up or having some restless sleep in the middle of the night or the end of the night," she said. 

Also, heartier foods like fiber-rich vegetables or heavy carbohydrates can keep your system awake and alert longer as the digestive processes finish. 

Kiraly explains that to get to sleep quicker and stay asleep better, one should also limit the number of fluids they have before bedtime. 

"If your body is processing those it could keep you up at night, even if you're drinking even water too late into the evening," she said. 

Dr. Kiraly also said that overindulging before bedtime can have consequences for people with chronic health problems like gastroesophageal reflux disease, diabetes, and more. 
And while there's no magic number to tell when you should stop eating before bed, Dr. Kiraly said a good rule of thumb is at least a few hours before you plan to sleep if it's a big meal. 

Many people turn to some foods that might actually help you sleep. 

"One of the first studies of how food impacts your sleep was on milk, and that was in the '70s," Kiraly said. 

Dr. Kiraly explained, saying, "For instance, when I was growing my dad would always take me downstairs if I couldn't sleep for a glass of warm milk and bananas."

"One of the first studies of how food impacts your sleep was on milk, and that was in the '70s," Kiraly said. "They do find that milk contains a higher amount of tryptophan, which is a precursor to serotonin that is one of our sleep promoting hormones. But we can't tell you how much. There just haven't been enough studies done at this point to say this is how much or this is what type of milk you'll need every night to sleep."

Other foods may contain the hormones that could help you get a few extra winks in. 

"Kiwis, tart cherries, salmon. Those all do have some significant levels of those hormones, that in theory, they can help people fall asleep," she explained. "But again, you're going to have to be eating or drinking those in sufficient quantities every night to have a reliable benefit from them, and even then it might be kind of a negligible benefit; maybe a few  extra minutes  of sleep here or there." 

And as for the age-old question of whether your diet changes your dreams, Kiraly said there's more research to be done, but that it could very well be the case. 
"Certainly there is a lot of anecdotal evidence of people saying, 'Oh, I ate this and I had this crazy dream.' It can happen, but I'm not saying that we know exactly why," she said.  "It does tend to happen, I think, anecdotally, after people eat spicier foods. I think that's because there are hormones that are released after a spicy meal and as your body tries to digest that, it can really kind of rev your system up."
So while there's some research to show that your diet can impact how well, or unwell, you're sleeping, Dr. Kiraly said the best bet is to focus on your other sleep habits. 

"Your biggest bang for your buck is going to be more from your sleep hygiene and avoiding that technology which is the biggest sleep no-no that people break," she said. 

She suggested that for the best night's sleep turn off the screens at least an hour before bed. Also, she said to make sure the room is quiet, dark, and a suitable sleeping environment.