How to Get Rid of Gnats: Find Which One You Have, Then Fix the Source

Illustration of the four insects people call gnats: fungus gnat, fruit fly, drain fly and phorid fly

Last checked: 5 December 2026. Every fact below is linked to its source, mostly US university extension services.

Short answer: “Gnats” in a US home are almost always one of four different insects: fungus gnats, fruit flies, drain flies or phorid flies. Each one breeds somewhere different and needs a different fix. Traps and sprays only kill the adults you can see. The infestation stops when you find and remove the place they are breeding, and that takes about three weeks because eggs already laid keep hatching.

Most guides on this subject give you a list of 15 or 20 remedies and leave you to try them all. This one does it the other way round: work out which insect you have (it takes a day), then do the three or four things that work on that one.

Step 1: Work out which “gnat” you have

All four are about an eighth of an inch long or smaller, which is why people call them all gnats. Look at where they gather and how they move.

Chart showing how to tell a fungus gnat, fruit fly, drain fly and phorid fly apart, and where each one breeds
How to tell the four apart. Illustration: NibDaily. Sources: UC IPM, University of Kentucky, University of Minnesota, University of Missouri.
What you seeProbablyWhere it breeds
Dark, mosquito-like, slow and weak in flight, hanging around houseplants or walking on the soilFungus gnatWet potting soil
Tan body with a dark rear end and red eyes, circling fruit, the trash or a glass of wineFruit flyOverripe produce, spills, drains, recycling
Fuzzy, moth-like, wings held like a roof over the body, resting on bathroom wallsDrain fly (moth fly)The slimy film inside drains
Small, dark, hump-backed, runs in short jerky bursts across surfaces instead of flying awayPhorid flyAny moist rotting matter, including a hidden plumbing leak

The descriptions are drawn from UC IPM (fungus gnats), the University of Kentucky (fruit flies), University of Minnesota Extension (drain flies) and University of Missouri Extension (phorid flies).

Two overnight tests that settle it

Diagram of the potato test in a houseplant pot and the overnight bag test over a sink drain
The two overnight tests. Illustration: NibDaily.

The potato test, for houseplants. Push a chunk of raw potato, cut side down, into the soil of each plant you suspect. Fungus gnat larvae are drawn to it. Lift it after a few days: tiny clear worms with shiny black heads on the underside mean that pot is a breeding site. UC IPM recommends this exact check.

The drain test, for sinks, tubs and showers. Before bed, tape a clear plastic food bag over the drain, or put a strip of tape over it sticky side down. Anything that hatches overnight and tries to fly out gets caught. Do one drain at a time, because the point is to find out which drain. The University of Kentucky and University of Minnesota both describe this method.

If neither test catches anything and the flies keep coming, go to the phorid fly section below.

Why it takes about three weeks, not one night

Every quick fix you read about (“get rid of gnats overnight”) kills adults. It does nothing to the eggs and larvae already in the soil or the drain, and those keep turning into new adults for days.

UC IPM gives the fungus gnat timeline at 75°F: eggs hatch in about 3 days, larvae feed for about 10 days, and adults come out of the pupa about 4 days after that. That is roughly 17 days from egg to adult, and faster in a warm room. Fruit flies can go from egg to adult in about a week, and a single female can lay around 500 eggs, according to the University of Kentucky.

So plan on treating the source for at least three weeks, and expect to still see a few adults during the first one. Seeing fewer each week is the sign it is working.

If it’s fungus gnats (houseplants)

These are the most common “gnats” in homes with plants. The adults do not bite and do not hurt plants. The larvae live in the top layer of wet soil and can damage roots, mainly on seedlings and young plants.

  1. Let the top of the soil dry out between waterings. This is the single biggest fix, because the larvae need moist soil. Empty the saucer under each pot so it isn’t sitting in water. If a mix stays soggy, repot with better drainage (more perlite or sand).
  2. Treat the soil with Bti. Bti is a bacterium that only affects fly larvae. It is sold as Mosquito Bits and Gnatrol: you soak the bits in your watering water. UC IPM notes it breaks down quickly indoors, so repeat about every five days for the three-week window.
  3. Catch adults with yellow sticky traps. Stick one in each affected pot. These do not end the infestation on their own, but they cut the number of egg-laying adults and show you, day by day, whether things are improving.
  4. For a stubborn case, use beneficial nematodes. UC IPM names Steinernema feltiae as the most effective nematode species against fungus gnats. They are mail-order only and perishable, so use them soon after they arrive.
  5. Use only pasteurized bagged potting mix when you repot, and keep opened bags sealed. Partly composted material is a common source.
  6. Quarantine new plants. Oregon State University Extension suggests keeping a new plant away from your others for a few weeks with a yellow sticky trap in it.

What about hydrogen peroxide?

You will see a peroxide soil drench recommended everywhere, usually one part ordinary 3% peroxide to four parts water. Extension advice on it is genuinely mixed. Cornell Cooperative Extension in Allegany County lists that mix as an option. Experts answering on the national Ask Extension service have told gardeners to try gentler controls first, and one advised avoiding peroxide and other home remedies altogether. A University of Maine Extension pesticide educator told the Bangor Daily News that pharmacy peroxide has not been tested or approved for use on plants.

Our reading: drying the soil and Bti have the strongest backing, so start there. If you do use peroxide, test it on one plant first.

What not to do

UC IPM says insecticides are rarely needed for fungus gnats in homes, and specifically warns against fogging indoors or spraying the flying adults. Spraying the air kills a few adults and leaves the larvae untouched.

If it’s fruit flies (kitchen)

  1. Find every breeding spot. The University of Kentucky list goes well beyond the fruit bowl: drains, garbage disposals, empty bottles and cans, the recycling bin, mops, cleaning rags, spilled juice under the fridge, and a single forgotten potato or onion at the back of a cupboard. Check all of them.
  2. Eat, refrigerate or throw out ripe produce. Cut away bruised or damaged parts. Produce from a garden or a store can arrive with eggs already on it.
  3. Set a funnel trap. Put a few ounces of cider vinegar in a jar, roll a sheet of paper into a cone and set it in the mouth of the jar. Flies go in and can’t find the way out. A drop of dish soap in an open bowl of vinegar also works, because it breaks the surface tension so they sink.
  4. Check your window screens. The University of Kentucky recommends tight-fitting 16-mesh screens. Fruit flies get through anything looser.

The same source is clear that spraying alone will not solve the problem while breeding continues. A spray is only worth using after the source is gone, to clear the last adults.

If it’s drain flies (bathroom or kitchen sink)

This is where most popular advice is wrong. Many guides tell you to pour bleach or boiling water down the drain. University of Minnesota Extension says plainly that hot water, boiling water, bleach and chemical drain cleaners are not effective against drain flies. The larvae live in a thick layer of gunk on the pipe walls, and liquid poured down the middle mostly runs past it.

  1. Confirm the drain with the overnight tape or bag test above.
  2. Scrub the inside of the pipe with a long, stiff drain brush to break up the slimy film. This is the step that actually removes the larvae.
  3. Follow with an enzyme or bacterial drain cleaner (sold as “biological” or “enzyme” drain treatments), which breaks down what the brush leaves behind. Repeat over several nights.
  4. Don’t forget the less obvious drains. Virginia Tech’s extension service notes drain flies also breed in rarely used sinks, toilets and overflow pipes, and around the drip pans and filters of dishwashers, refrigerators, air conditioners and dehumidifiers. A guest bathroom that hasn’t been used in a month is a classic source.

If it’s phorid flies (and nothing above worked)

Phorid flies look a lot like fruit flies but behave differently: they tend to run in jerky bursts across counters and walls. Michigan State University Extension says they breed in moist, decaying plant or animal matter, go from egg to adult in about 10 days, and live as adults for one to two months.

That long adult life and wide choice of breeding spots make them the hardest of the four. Check trash cans, recycling, garbage disposals, floor drains, and anywhere food or water may have collected out of sight. If the flies keep appearing near a floor or a wall and you can’t find a source, a broken drain or sewer line is a real possibility. University of Minnesota Extension notes that confirming a break under a slab can mean opening the floor, which is a job for a plumber, not a trap.

Remedies that don’t hold up

  • Bleach or boiling water for drain flies. Not effective, per University of Minnesota Extension. Bleach also produces toxic gas if it meets ammonia or acidic cleaners, including vinegar, so never mix it with them.
  • Spraying clouds of adults. Kills what you hit and leaves the breeding site untouched. UC IPM advises against fogging or spraying flying adults indoors.
  • Traps as the whole plan. Traps measure and reduce adults. They are part of the fix, not the fix.
  • Candle-in-water traps. Often suggested online. An open flame left near fabric, curtains or paper is a fire risk for a modest catch. A vinegar trap does the same job safely.

When to call a professional

Call a pest control company or a plumber if you have done the right steps for your insect for three weeks and numbers are not falling, if flies are coming from a wall, floor or ceiling, or if you notice a sewage smell. Those usually point to a hidden source that DIY treatment cannot reach.

Frequently asked questions

Do gnats bite?

None of the four indoor insects in this guide bite people. Biting “gnats” you meet outdoors, such as black flies and no-see-ums, are different insects with different control methods, and this guide does not cover them.

Are gnats harmful?

Mostly they are a nuisance. Fruit flies can carry bacteria onto food, according to the University of Kentucky, and drain and phorid flies come from dirty places, so keep them off food surfaces. Fungus gnat larvae can damage seedling roots.

Why do I have gnats in winter?

Homes stay warm all year, so indoor gnats breed in any season. Houseplants are often watered more often than they need in winter, when they grow slowly, which keeps the soil wet for fungus gnats.

How long until they’re completely gone?

Plan on about three weeks of treating the source, because of the life cycle explained above. If numbers are not clearly falling after that, the source has not been found.

Ants too? See our guide: How to get rid of ants.

What we checked, and what we didn’t

We read the extension publications linked in this guide on 5 December 2026: UC IPM Pest Note 7448 on fungus gnats (last revised August 2013), University of Kentucky ENTFACT-621 on fruit flies, University of Minnesota Extension’s page on flies (reviewed 2024), Virginia Tech ENTO-414 on drain flies, University of Missouri G7388 and Michigan State University Extension on phorid flies, and the Oregon State, Cornell, Maine and Ask Extension guidance cited above.

We did not test these methods ourselves for this article, and we have not measured how many flies each trap catches. Product names (Mosquito Bits, Gnatrol) are given because the extension sources name them. We have no commercial relationship with any of them and this article contains no affiliate links.

See more NibDaily in your Google results: add NibDaily as a preferred source on Google.

ABOUT THE EDITOR

How we check our facts · Report an error

Get every new NibDaily article by email

One short email when we publish. No spam. Unsubscribe in one click.