Ever wake up with your head throbbing and instantly regret that glass of Cabernet you drink at dinner? Science says you’re not alone. A new study in the Journal of Scientific Reports from University of California, Davis has finally revealed why drinking red wine, even in small amounts, can lead to an extra-painful headache more so than its white counterparts.

This type of headache, known colloquially as a “red wine headache,” usually occurs within 30 minutes to three hours after drinking. Though people have been aware of this phenomenon for a long time, the reasoning behind it has largely remained a mystery. According to the study, which was published Monday, red wine has a much higher level of quercetin, a flavanol present in many fruits (including grapes) and vegetables. The U.C. Davis research group found that this flavanol and its metabolites can interfere with the body’s ability to metabolize alcohol. While the compound is an antioxidant that is actually sold as a health supplement on its own, it can be problematic when consumed with alcohol.

“When it gets in your bloodstream, your body converts it to a different form called quercetin glucuronide,” says Andrew Waterhouse, co-author and professor emeritus with the U.C. Davis Department of Viticulture and Enology. “In that form, it blocks the metabolism of alcohol.”

The study proposes that quercetin-3-glucoronide, a compound derived from the various forms of quercetin found in red wine, can inhibit the enzyme ALDH2, resulting in elevated acetaldehyde levels. ALDH2 is an enzyme responsible for the breakdown of acetaldehyde — the first product generated during the metabolism of alcohol — and is known to be inflammatory. Those with a dysfunctional ALDH2 variant are known to suffer from symptoms such as headache, facial flushing, and nausea.

“We postulate that when susceptible people consume wine with even modest amounts of quercetin, they develop headaches, particularly if they have a preexisting migraine or another primary headache condition,” says co-author Morris Levin, professor of neurology and director of the Headache Center at the University of California, San Francisco.

“We think we are finally on the right track toward explaining this millennia-old mystery,” he says. “The next step is to test it scientifically on people who develop these headaches, so stay tuned.”