Getting rid of gnats starts with figuring out which type you have, because the fix for each one is completely different. The three most common indoor gnats are fungus gnats (hovering around houseplants), fruit flies (buzzing near your kitchen), and drain flies (clinging to walls near sinks). Once you identify yours, you can target the breeding source and break the cycle in two to three weeks.
Identify Which Gnat You Have
All three species are roughly the same size, about an eighth of an inch long, but they look and behave differently.
- Fungus gnats look like tiny mosquitoes with dark bodies and light-colored legs. You’ll see them swarming above the soil of your houseplants and showing little interest in going anywhere else. They breed in moist potting soil.
- Fruit flies look like miniature house flies with striped abdomens and red or black eyes. They cluster around fruit bowls, trash cans, recycling bins, and kitchen drains. They’re attracted to ripe or rotting fruit, sugary juices, and alcohol.
- Drain flies are fuzzy and moth-like, light gray or tan with dark-bordered wings. They breed inside the sludgy biofilm that lines drain pipes, and you’ll spot adults clinging to nearby walls and ceilings.
Where you see them is the fastest way to tell. Gnats near plants are fungus gnats. Gnats near food are fruit flies. Gnats near drains are drain flies. The species matters because each one breeds in a different material, and killing adults without destroying the breeding site won’t solve the problem.
Getting Rid of Fungus Gnats
Fungus gnats lay eggs in moist soil. The larvae feed on organic matter and root hairs in the top few inches of your potting mix. A single generation completes its entire life cycle in about 17 days at typical room temperature: eggs hatch in three days, larvae develop over ten days, and adults emerge four days after pupation. That speed means a small problem becomes a big one fast, but it also means you can wipe them out in two to three weeks if you hit both adults and larvae at the same time.
Kill the Larvae in the Soil
The most reliable treatment is BTi (Bacillus thuringiensis subspecies israelensis), a naturally occurring soil bacterium sold as “Mosquito Bits” or “Mosquito Dunks” at most garden centers. It’s toxic only to the larvae of fungus gnats, mosquitoes, and black flies. The EPA has confirmed it poses no risk to humans, pets, or honey bees, and it’s approved for use in organic farming. It won’t harm your plants or interfere with fertilizer.
Soak about one tablespoon of Mosquito Bits (or a quarter of a dunk) per gallon of water for 24 hours. Use this treated water every time you water your plants. The larvae eat the bacteria and die, but you need to keep using it for at least two to three weeks to outlast the existing life cycle. Replace the BTi in your watering vessel every 30 to 60 days.
A faster but less thorough alternative is a hydrogen peroxide soil drench. Mix one part standard 3% hydrogen peroxide with four parts water and pour it through the soil. It will fizz on contact with larvae. Let the soil dry out completely before watering again.
Stop Adults From Laying New Eggs
Let the top inch of soil dry out between waterings. Fungus gnats need moisture to lay eggs, and dry surface soil is inhospitable to them. For plants that tolerate it, bottom watering (setting the pot in a tray of water and letting soil wick it up) keeps the surface dry while still hydrating roots.
A layer of sand or fine gravel on top of the soil creates a physical barrier. A half inch to one inch of play sand or horticultural sand is enough. Adult gnats can’t dig through it to reach the soil, and any larvae already below the surface can’t emerge through the weight. This is especially useful for seedlings and plants you water frequently.
Trap the Adults
Yellow sticky traps placed near the soil surface catch adult gnats effectively. They won’t solve the problem on their own, but they reduce the number of egg-laying adults while your soil treatments work through the larval population.
Getting Rid of Fruit Flies
Fruit flies breed on ripening or decomposing fruit and in any spot where sugary organic residue collects. The fix is almost entirely about eliminating their food sources.
Remove the Breeding Sources
Store ripe fruit in the refrigerator. Throw away anything overripe. Take out kitchen trash and recycling daily, especially containers with juice, beer, or wine residue. Clean your garbage disposal by running it with cold water for 30 seconds. Wipe down counters where fruit has sat. Rinse bottles and cans before putting them in recycling. Fruit flies lay eggs directly on rotting fruit and in the gunk that collects inside drains, so every bit of exposed organic material is a potential nursery.
Trap the Remaining Adults
Fill a jar with about a quarter cup of apple cider vinegar and add a few drops of liquid dish soap. The vinegar’s fermentation smell attracts the flies, and the dish soap breaks the surface tension of the liquid so they sink and drown instead of landing and flying away. Punch a few small holes in the lid or cover the jar with plastic wrap poked with a toothpick to let flies in while making it hard to escape. Place traps near the areas where you see the most activity.
A nearly empty bottle of wine or beer works on the same principle. Leave it out with a drop of dish soap inside. Fruit flies are drawn to the fermented scent and get trapped in the narrow neck.
With food sources eliminated and traps catching adults, fruit flies typically clear up within a week or two.
Getting Rid of Drain Flies
Drain flies breed inside the slimy biofilm that coats the inside of drain pipes. This biofilm is a structured microbial layer that resists chemical penetration, which is why common quick fixes often fail. Bleach kills adult drain flies on contact but doesn’t penetrate the biofilm where larvae live. Boiling water loses too much heat as it travels through the pipe to reach most of the buildup. Enzyme-based drain cleaners work slowly, need repeated applications, and rarely eliminate the full biofilm layer that can extend several feet along the pipe interior.
The most effective approach is mechanical cleaning. Use a stiff drain brush to physically scrub the inside of the drain body and remove the accessible biofilm. This destroys the immediate breeding site. Follow up with an enzyme drain cleaner if you want, but treat it as supplementary to the scrubbing, not a replacement.
For floor drains you rarely use (basement drains, utility room drains), the simplest long-term fix is a drain cover or one-way silicone valve that drops into the drain opening. This physically blocks flies from entering or exiting while still allowing water to flow through. Running water through unused drains weekly also helps prevent biofilm from building up in the first place.
Prevention That Works Long-Term
Most gnat problems come back because the conditions that attracted them haven’t changed. For fungus gnats, the single most effective habit is avoiding overwatering your houseplants. Soil that stays constantly wet is an open invitation. Using well-draining potting mixes with perlite or bark helps the top layer dry faster. Keeping a sand top-dressing on your pots provides ongoing protection with no extra effort.
For fruit flies, the pattern is almost always seasonal. As summer fruit comes into the kitchen, so do the flies. Refrigerating ripe produce and keeping a vinegar trap on the counter during warm months catches problems before they build. Clean your kitchen drain and garbage disposal once a week with hot water and a scrub brush.
For drain flies, regular use of your drains is the best prevention. Biofilm accumulates in pipes that sit stagnant. If you have drains that go weeks without water flow, flush them weekly. Periodic brushing of the drain opening keeps the biofilm from reaching the thickness where flies can breed.