Next time you open a bottle of merlot or chardonnay, be sure to thank the vintner. And you might want to toast the worms, as well.

Everyday earthworms are the latest solution to a thorny problem that most wine drinkers never consider: wastewater disposal.

Producing a single glass of California wine may require as much as 14 gallons of water. Much of that water is used to clean the winery and bottling equipment after processing grapes. At most wineries, the wastewater is moved through a series of aeration ponds, where air is pumped through the water for several weeks while bacteria break down contaminants.

Now a Chilean company, BioFiltro, offers an alternative: spraying the wastewater into giant bins filled with earthworms. Fetzer Vineyards, located in California’s Mendocino County, has signed on to become the first American winery to use the process to treat 100% of its wastewater.

The industrious worms are expected to clean the water just as well but in only four hours. They require almost no electricity, and the only byproduct is worm excrement – also known as castings – which can be returned to the vineyard as a nutritious fertilizer.

“This system is using nature. It’s using worms and microbes to treat all of our winery wastewater,” says Josh Prigge, director of regenerative development at Fetzer.

BioFiltro has begin to install its system at Fetzer, which expects to have it fully operational later this year, in time for the 2016 grape harvest. Fetzer and BioFiltro declined to disclose the system’s cost.

Wineries have historically relied on aeration ponds to treat their wastewater. Such a pond requires pumping air through the dirty water to get bacteria to breakdown contaminants, a process that takes more time than the earthworm-based process that Fetzer Vineyards is trying out. Photograph: BioFiltro

Fetzer has long been a sustainability leader in the wine industry, having converted its entire operation to use renewable energy sources such as solar, for example, back in 1999. It also recently became the largest winery certified as a B Corporation, a process requiring Fetzer to meet rigorous environmental and social standards.

The drought in California has motivated many vineyards and wineries to slash their water demand. Switching to drip irrigation is a common move, as is adding low-flow fixtures and meters to better measure consumption. Some have drilled wells to avoid diverting water from streams, or they have switched to dry farming, which avoids irrigation by relying on rain and techniques to retain moisture in the soil.

The BioFiltro process was initially developed by Jose Toha Castella, a biophysics professor at the University of Chile, and commercialized by one of his students, Alex Villagra, a co-founder of the company. It has since been used at 129 installations in six countries, in environments from Antarctica to the Atacama Desert, and in a variety of wastewater settings from human and dairy cattle sewage to slaughterhouses and wineries in California, Washington and elsewhere, says Mai Ann Healy, the firm’s regional manager in the US.

“The worms are the stars of our facility,” Healy says. “As they digest and break down the contaminants, their guts are producing these bacteria, essentially. The bacteria are actually the ones who work 24-7 and don’t get as much credit.”

At each installation, BioFiltro builds large concrete “treatment” boxes, which contain 12,000 worms per cubic yard. These have an open chamber at the bottom to maintain air follow, then are lined bottom to top with large river cobbles (rocks), wood shavings three feet thick, then a top layer of worms and bacteria. The concrete boxes are open to the sky, and the wastewater is simply sprayed on top of the worm piles.

BilFiltro designs different worm and bacteria recipes, which depend partly on the types of worms that can thrive in local conditions, to treat a particular type of wastewater. Large solids in the wastewater collect on the wood shavings and are then consumed by the worms. Microscopic solids are consumed by the bacteria, both on the wood shavings and in the worms’ digestive tracts.

Fetzer will have three treatment boxes, each 36-feet wide, 200-feet long and six-feet deep. An estimated 100m worms in total, mostly the common California red worms, will be on duty, Healy says.

The vanguard of that worm workforce has already started in a kind of “incubator” at the Fetzer winery, Healy says, where they are being gradually exposed to the wastewater so they can acclimate.

BioFiltro worms at work at a campground in Torres del Paine National Park, in the Chilean side of Patagonia. The system contains wood shavings, earthworms and bacteria to help it treat wastewater and reuse it for flushing toilets. Photograph: BioFiltro

Once or twice a year, BioFiltro will visit the winery to collect worm castings from the treatment boxes, which Fetzer will combine with compost from other parts of its operation and then apply throughout its vineyards to nourish the soil.

Sanjai Parikh, an associate professor of soil chemistry at the University of California, Davis, says BioFiltro looks like a promising option for treating winery wastewater.

“That type of approach of recreating the natural system in this contained environment, I think, is a very good approach and could be really beneficial. It’s something that wineries and tomato canneries and similar facilities should all consider,” Parikh says.

Parikh, who recently co-authored a study that examined wastewater management at wineries, said most of them use aeration ponds, a proven technology but one that is very energy intensive because air must be constantly pumped and mixed with the wastewater to ensure bacterial contact.

Such ponds are also slow to clean wastewater – it can take weeks or even months. This requires lots of land area to hold the water since it continues to accumulate with ongoing operations. And the process tends to generate offensive odors. These issues don’t exist with BioFiltro’s process, Healy says.

But there’s one potential downside with worm processing: it’s not much more effective at removing salts from wastewater than pond aeration. Salts naturally accumulate in wastewater from agricultural operations, and this is particularly true in winemaking because many of the cleaning agents used contain sodium.

Salt makes wastewater less useful for irrigation because it causes clay particles in the soil to bind together, preventing the soil from absorbing water, Parikh says. Many plants also won’t grow in salty water or soil. Dilution is the preferred and cheap way to reduce salt, but Parikh’s research reveals another option: replacing sodium-based cleaning chemicals with the potassium-based alternatives in winemaking. Potassium in wastewater may actually improve soil fertility.

“What we see across the board is that, yes, winery wastewater has exciting potential to be reused, and you could probably use it for irrigation,” Parikh says. “But it’s always going to be a big challenge having a way to dilute water when salts are too high, or a way to get rid of it when it’s far too high.”

Currently, Fetzer disposes of its treated wastewater by spreading it on land, where it then filters into the groundwater table – a common practice.

Once the BioFiltro process is operating, the treated wastewater will be plumbed to a pond and used to irrigate landscaping. That pond is now filled from wells and a nearby stream, and Fetzer hopes to stop using those water sources. It also plans to build a rainwater catchment system to further reduce reliance on streams and aquifers.

With more testing and quality control, the company hopes to use the worm-processed wastewater to irrigate its vineyards, Prigge says, effectively closing the loop on its water consumption.

“This is what we feel is the evolution of corporate responsibility,” he says. “We don’t want to just minimize our impacts. We want to eliminate those impacts.”