A woman wearing a face mask sleeps on a bench in Seoul.Ed Jones / AFP

In 1909, the Japanese scientist Kuniomi Ishimori collected spinal fluid from sleep-deprived dogs and injected it into active, rested pooches. Within hours, the latter fell into a deep sleep. By coincidence, a pair of French researchers did the same experiments a few years later and got the same results. These studies, and others like them, suggested that the blood of sleepy animals contains some kind of soporific secret sauce of chemicals. Ishimori called these “hypogenic substances.” Others labeled them “somnogens.”

The sources of these sleep-inducing chemicals have proved surprisingly elusive, and scientists have found only a few that fit the bill. Now Hirofumi Toda from the University of Pennsylvania has discovered another—a gene called nemuri that triggers sleep, at least in fruit flies. Unexpectedly, it also becomes active during infections and acts to kill incoming microbes. It seems to be part of a self-regulating system, analogous enough to an internal thermostat that we might call it a sleep-o-stat. It can send animals to sleep when they most need shut-eye, whether because they’re sick or because they just haven’t slept enough.

This sleep-o-stat works separately from the daily body clocks that make us feel more tired at night. And while the latter has been thoroughly scrutinized by scientists, the former is still largely mysterious. “What makes us sleepy when we’ve been awake for a long time?” asks Amita Sehgal, who led Toda’s project. “We still don’t really have answers to that.”

Toda began by looking for genes that, if switched on, would make flies sleepier. To that end, he worked with flies from 8,000 different strains that had each been engineered to activate a different gene when fed a triggering chemical. Toda placed these flies individually into tubes that were monitored with infrared beams. When awake and mobile, the insects regularly tripped the beams; when asleep and still, they did not. A computer monitored the entire captive swarm, recording their movements and noting any that were sleeping more than usual.

This monumental effort was successful—just. From 8,000 possible genes, Toda found only one that induced sleep. That was nemuri, which the team named after the Japanese word for sleep. It had never been thoroughly studied before. “When we first got it, we didn’t know what it was,” says Sehgal.

If flies are deprived of sleep, because the team was either regularly shaking their tubes or feeding them with caffeine, the nemuri gene becomes more active—but only in a single pair of neurons within the insects’ brains. When it whirs into action, it produces a protein (of the same name) that then acts on a fan-shaped part of the brain that’s known as a control center for sleep. If Toda switched nemuri on deliberately, flies slept 20 to 30 percent longer than normal peers. They slept more deeply, too: They were much less likely to wake up when their tubes were bumped, and the few that were roused were slow and sluggish.

“It’s very interesting work,” says Chiara Cirelli from the University of Wisconsin at Madison. She and others have identified genes in flies that are important for a good night’s rest and, when disabled, result in less sleep. But this is the first time anyone has done the reverse: increase the activity of a gene, and trigger more sleep.

“Until this study was conducted, relatively few somnogens were known,” says Susan Harbison from the National Institutes of Health. “This study also suggests that few such molecules may exist.” After all, if Toda tested 8,000 genes and found just one hit ... maybe there aren’t that many hits to find?

But there must be at least a few more, because nemuri can’t be the whole story. If it’s responsible for sending tired flies to sleep, then disabling it should disrupt sleep, says Cheryl van Buskirk at California State University at Northridge. And it didn’t. When Toda used the gene-editing technique called CRISPR to deactivate the gene, flies still slept, and for the usual amount of time. They were much easier to wake and took longer to nod off again. But “since sleep and sleep rebound are both largely intact, nemuri isn’t likely a major component of the sleep homeostat,” Van Buskirk says.

Sehgal thinks nemuri is probably a bit player when it comes to daily sleep, but becomes very important during times of stress, sleep deprivation, and sickness. Indeed, her team showed that the Nemuri protein is an antimicrobial peptide, or AMP—one of several small molecules that, as their name suggests, kill microbes.

This ability is intertwined with nemuri’s effects on sleep. Like us, flies sleep more when they get infections. The team found that these bouts of sickness-induced bed rest were longer when they deliberately switched nemuri on, and shorter if they disabled the gene. “There is an intimate link between sleep and the immune system,” Sehgal says.

Read: Why some people respond to stress by falling asleep

A few of the other possible somnogens also moonlight as part of the immune system. “This may represent the tip of the iceberg,” adds Van Buskirk, in terms of substances with dual roles, “directly combatting [infections] and promoting sleep while the battle ensues.”

It may seem strange to devote all this effort to understanding sleepy flies, especially when nemuri doesn’t have an obvious human equivalent. But Sehgal notes that humans do produce more than 100 AMPs, which might play a similar role. And she notes that there’s a long history of sleep researchers making discoveries in flies that later turn out to be important in humans.

Twenty-five years ago, while working in the lab of Michael Young, Sehgal helped to show that a gene called “timeless” controls the daily body clocks of flies. There wasn’t an obvious human equivalent of that either, and Sehgal says some researchers were skeptical that the discovery had any relevance. But in time, a human version was discovered, and it’s involved in several important diseases. For this work and others, Young won a Nobel Prize in 2017. “We have been down this road before a couple of times,” Sehgal says.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.