If you ever opened your washing machine and wondered how something designed to keep your clothes and linens clean can smell so foul, you’re not alone.

Several years ago, we had a top-loading washer with a problematic baffle, leading to standing water and an awful smell. This stench ended up on our clothes. We eventually had to replace the washer because we didn’t address the problem early enough.

Whether you use a top- or front-loading washer, odors like rotten eggs, wet dog and others can develop for various reasons. Fortunately, once you figure out the cause, it’s usually easy to fix a smelly washing machine. Here are some of the most common reasons why your washing machine smells bad.

Mold and Mildew Growth

Mold and mildew growth is the main trigger for a pungent smell, linked to many of the other causes below.

Front-loading machines are especially prone to mold on the rubber door gaskets where water collects, producing a musty odor that can get on your clothes as well. The easiest fix: “Keep your door open between loads to let the machine air out,” says appliance technician Jason Carter of Simply Swider.

You can also manually clean the gasket and drum with a cloth, or run a hot water cycle using bleach, vinegar or a specialized washer cleaner like Affresh. Also, avoid leaving damp clothes in the machine for extended periods.

Detergent Residue

Using too much laundry detergent or non-high efficiency (HE) detergent in an HE washer can cause residue to build up on the drum, dispenser, hoses and/or filter. This creates a sticky, slimy layer that can trap dirt, resulting in mold, mildew, bacteria and foul odors.

“To prevent this, you should use the correct amount of detergent for each load size and clean out any residue buildup from the soap dispenser or drawers on a regular basis,” says Mark Buskuhl, founder and CEO of Ninebird Properties.

If you have a front-loading or HE top-loading washer, be sure to use HE detergent, which produces fewer suds and rinses more effectively than regular detergent. Also, choose liquid detergents over powders; they’re less likely to leave behind residue.

Clogged Drain, Pump or Filter

Dirty moldy washing machine sealing rubber and drum close up. Mold, dirt and limescale in washing machine. Home appliances periodic maintenanceIuliia Mikhalitskaia/Getty Images

Lint, hair, coins, buttons and other debris that gets stuck in the drain hose, pump or filter can lead to a washing machine that won’t drain, forming a stagnant pool that stinks. Also, the scum accumulating inside the machine from a clog creates a breeding ground for bacteria, causing an unpleasant odor.

Andrew Brown of This Fixed House recommends “regularly cleaning the filter and ensuring the drain isn’t obstructed, and also checking that drain pipes are not kinked or bent to allow for the accumulation of scum.”

Try using a lint trap or mesh bag to catch any lint or hair from your clothes before they enter the washer.

Washing Mostly in Cold Water

While washing laundry in cold water can save energy and money, it unfortunately can also cause an odor.

“Cold water may not be able to dissolve or rinse away all the dirt, oil, and detergent from your clothes or your washing machine,” says Mark Morris of Deluxe Plumbers. “This can leave behind a residue that can harbor bacteria and odors.

“Cold water may also not be able to kill all the germs or bacteria that may be present on your clothes or your washing machine, which can cause a foul smell that can spread to your clothes.”

To avoid this issue, periodically run hot water wash cycles with no laundry to clean and sanitize your machine.

Hard Water

Hard water’s high mineral content of calcium or magnesium can react with detergents and reduce cleaning efficiency. This can lead to deposits building up on the heating element, drum, pipes or hoses, attracting bacteria and producing odor.

“Install a water softener system in your home to reduce the mineral content of your water,” Morris says. “You should also use a descaler product once every three months to remove any deposits from your washing machine.”

Dirty Water In Impeller

If you have a front-loading machine, check the impeller, i.e. the low-profile cone, wheel, fin or disc that spins to gently rub clothes against each other to loosen stains. Carter says dirty water can seep into and around the back of the impeller and cause a strong stench.

Standing Water

the filter of the washing machine is clogged. Plumber repairs washing machine.Elena Gurova/Getty Images

Water is one of the most common causes of washing machine smells.

“If there are issues with the drain filter, pump or drainpipe, the machine fails to fully drain all of the wastewater during the drain cycle,” says Brown. “This will leave standing water within the drain system leading to stagnation and bad odors.”

Poor Ventilation

Poor ventilation in the area surrounding your washing machine also can cause bad odors. “If there is no air circulation, moisture and humidity build-up inside the machine, which can create an unpleasant smell,” Buskuhl says.

To remedy this, make sure there’s adequate ventilation around your washing machine so excess moisture and heat can escape.

Faulty Drain Hose Installation

Be sure to check if the drain hose is properly installed as that could also cause a pungent smell.

Fantastic Service‘s appliance technician David Miloshev says a poorly positioned drain hose may let water accumulate, producing a bad smell. “The hose should have a U-shape to prevent backflow,” he says.

Wrong Detergent

Fabric softenerKinga Krzeminska/Getty Images

According to Sabrina Tretyakova, a certified cleaning technician at Fortador, “Using the wrong type of detergent can prevent the washer from adequately rinsing clothes, leaving considerable soap scum and grime from your laundry, and leading to bacterial accumulation and foul odor.”

Read your owner’s manual to determine the detergent suitable for your machine and water type. Also, properly measure the amount of detergent. Don’t use more than called for, no matter how soiled your clothes.

Infrequent Use

Finally, it could be as simple as not running your washer enough. Professional cleaner Kyle Leman of Crossroads Foundation Repair said infrequent use can contribute to stagnant water and resultant smells.