You go to sleep with a cool, fresh glass of tap water by your bed and wake up to it tasting decidedly...off. Ever so slightly more dirt-like, I’d say. Musty, heavy, or oily, others have said. The taste difference is subtle and hard to describe, in a way that leads people who haven’t noticed to claim it doesn’t exist. So naturally, I called up a scientist to sort things out.

“I know exactly what you’re talking about,” says Susan Richardson, a chemist at the University of South Carolina. “Funny, I’ve been doing research on drinking water for 26 years, and I’ve never thought about this question before.” In fact, Richardson emailed several of her colleagues working at water utilities and the like, all of whom said they had never been asked this question before. “It’s the simple things that nobody thinks about,” she says.

Nobody has published a study on why water goes stale overnight, as far as we know. But Richardson and her colleagues did put their scientific minds together to come up with some answers—at least, some very probable answers. I also called up a water sommelier, Martin Riese, because that’s a job that apparently exists in LA.

Going Stale

The biggest factor, says Richardson, is likely a simple, indirect one: temperature. “Like warm beer versus cold beer,” she says. The longer a beer has been outside of the fridge, the more its sourness, hoppiness, and whatever off-notes it has get amplified. Tap water comes in through pipes underground, where it is generally cooler. And plenty of us then add ice or drink refrigerated water.

As water rises to room temperature, its aroma and bouquet, so to speak, really open up. “When you chill something extremely,” says Riese, “your taste palate’s completely gone.” We often use “taste” colloquially to mean “smell,” and smell is a function of molecules tickling cells in our noses. The warmer the drink, the faster the molecules are bouncing around, and the stronger the aroma. Riese always tastes his premium waters—such as Danish spring water1—at room temperature. He recommends drinking water chilled to a cool but not cool 59 degrees Fahrenheit—like, you know, a fine red wine.

But temperature doesn’t tell the whole story, and more chemistry is at play.

If you’ve ever successfully raised pet fish, you’d probably had to leave out tap water for chlorine to off-gas. (If you’ve ever unsuccessfully raised pet fish, that may be why.) Water treatment plants add chlorine to wipe out potentially deadly pathogens. Chlorine is volatile, and it quickly dissipates into the air. At this point, we tap water drinkers may just be conditioned to think chlorine means fresh water. “If you have something like swimming pool, that’s not good,” says Richardson. “But just a little bit of chlorine may make it seem refreshing.”

(Riese, who grew up in Germany drinking unchlorinated water, disagrees here on aesthetic grounds. Much to his chagrin, LA’s water—which has to travel hundreds of miles from the mountains and the Colorado River—is heavily treated with chlorine and ammonia. “That really drives me crazy,” he says.)

Dissolved gases are another part of the taste. As water sits out, small amounts of carbon dioxide dissolve into the water. This forms carbonic acid, which may lower the pH just slightly. Tiny amounts of other gases, like acetone and aldehydes, may dissolve in, too. “It’s very difficult to have a pure water sample for long,” says Richardson, who would know because she has to use completely pure water in her research. Leave purified water out for even 30 minutes, and it quickly becomes impure. “It’ll drive me nuts in my lab,” she says. Temperature plays another indirect role, too: Cold water generally holds more dissolved gases. Additionally, some oxygen may dissolve out of the water over time.

But if you start leaving your water out for days and days, then, finally, microbes enter the equation. Algae make earthy-smelling molecules like geosmin and 2-methylisoborneol, to which the human nose is incredibly sensitive. Geosmin, incidentally, also gives rainstorms their post-rain aroma and catfish their muddy taste.

Earlier this year, people bombarded Berkeley’s water utility company with complaints about an earthy taste after it began drawing from a higher, algae-filled part of a reservoir. The taste was harmless once the water was treated. If algae is growing in your water glass, it’s obviously high time to chuck it. An overnight sit won’t do anything to make water unsafe to drink though. The water will just taste a little funky, and now you know the chemistry of why.

1-UPDATE 5:40 PM EST 08/18/15: This story was updated to reflect the correct origin of the Danish water.