You’re low on sleep and feeling peckish. Do you reach for carrots and celery sticks?

Heck no! Bring on the doughnuts, the pizza, the fries.

Ever wonder why?

It turns out your nose and your brain are having a failure to communicate.

Researchers from Northwestern University’s Feinberg School of Medicine say your olfactory system and the way it’s affected by lack of sleep is at the root of why we crave more calorie-dense, high-fat food after those sleepless nights.

When you’re sleep deprived, your olfactory system tends to kick into hyperdrive, intensifying food odors to the brain so it can better distinguish between food and non-food smells, according to a study published Tuesday in the journal eLife. The next thing that happens is a kind of communication breakdown with other parts of the brain that receive food signals. And that ends up affecting food choices.

“When you’re sleep deprived, these brain areas may not be getting enough information, and you’re overcompensating by choosing food with a richer energy signal,” said senior author Thorsten Kahnt, an assistant professor of neurology at the medical school.

“But it may also be that these other areas fail to keep tabs on the sharpened signals in the olfactory cortex,” he added. “That could also lead to choosing doughnuts and potato chips.”

Past research has shown that sleep deprivation increases certain endocannabinoids. These naturally produced neurotransmitters bind to cannabinoid receptors in the brain — yes, the same receptors that get a workout during cannabis use — affecting feeding behaviors and how the brain responds to food odors.

The Northwestern researchers wanted to see if changes in what people chose to eat when they were sleep deprived was related to how the brain responds to food smells and whether that is due to changes in endocannabinoid levels.

In other words, “what makes our brain respond differently that makes us eat differently?” Kahnt said.

So the researchers devised an experiment with 29 men and women, ages 18 to 40. One group got a normal night’s sleep. Then four weeks later, they were only allowed to sleep four hours. The order was reversed for the second group.

The day after each night, the participants were served a controlled menu of breakfast, lunch and dinner, but were also offered a buffet of snacks.

“After being sleep deprived they ate food with higher energy density [more calories] like doughnuts, chocolate chip cookies and potato chips,” said Kahnt.

The researchers then measured endocannabinoid blood levels of the participants. They found the levels were elevated when the study subjects were sleep deprived, and that increase was related to food selection. They went more for the sweets and junk food.

Scans were also conducted on particular regions of the participants’ brains. One region, the piriform cortex, is the first area to get input from the nose. The other scanned area was the insular cortex or insula, the part of the brain that gets signals about taste and smell that affect food intake, as well how much food is in the stomach. They found there was less communication between the two parts of the brain when the subjects were sleep deprived.

“When the piriform cortex does not properly communicate with the insula, then people start eating more energy-dense food,” Kahnt said.

What can help us resist that lure of junk food?

Get enough sleep, for starters. And if you can’t, at least try to avoid temptation.

“Our findings suggest that sleep deprivation makes our brain more susceptible to enticing food smells,” Kahnt said. “So maybe it might be worth taking a detour to avoid your local doughnut shop next time you catch a 6 a.m. flight.”