The fastest way to get rid of gnats is to identify which kind you have and remove their breeding source: for fruit flies, toss overripe produce and set out an apple-cider-vinegar-and-dish-soap trap; for fungus gnats, let your houseplant soil dry out and treat it with a diluted hydrogen peroxide solution; and for drain flies, pour boiling water down the drain a few times a week to clear the gunk their larvae live in. Traps catch the adults, but eliminating the food and breeding source is what actually ends the infestation. Here’s how to tell them apart and clear each one.
How To Get Rid of Gnats

What are gnats?
“Gnat” isn’t one species — it’s a general term for several small flying insects. The three most common in homes are fungus gnats, fruit flies, and drain flies. Each has different habits, so identifying yours makes them far easier to eliminate.
Fungus gnats
- Small flies from the superfamily Sciaroidea
- Dark colored with long legs
- Feed on fungi in damp soil
- Weak fliers — more often seen walking than flying
- Harmless to humans and healthy plants, but can damage seedlings
Fungus gnats live in soil fungus and get indoors on houseplants or through gaps and open windows.
How to get rid of fungus gnats. They’re drawn to houseplants, especially overwatered ones where fungus grows or roots are rotting. Watering less often (letting the top inch or two of soil dry between waterings) is the single best control. Topping pots with sand or fine gravel also blocks the gnats from reaching the soil to lay eggs.

Fruit flies
- Species from the genus Drosophila
- Tan/brown with round bodies, often red eyes
- Feed and breed on overripe fruit and vegetables
- Fast, darting fliers
- Harmless to humans
Fruit flies are sometimes called “vinegar flies” because they’re drawn to the acetic acid produced by fermenting fruit — not fresh or unripe produce. The fix: don’t leave overripe fruit out, refrigerate produce when possible, and keep trash sealed.

Drain flies
- From the family Psychodidae (“moth flies”)
- Moth-like, with short, fuzzy bodies
- Breed in drains, where larvae feed on the organic slime
- Mostly nocturnal, but drawn to light
How to get rid of drain flies. Drain flies breed in the gunk inside drains, so treat the drain itself. Pouring boiling water down it 2-3 times a week for about three weeks kills the larvae, pupae, and adults and breaks the cycle. Mechanically scrubbing the pipe with a drain brush to remove the slime film is even more effective, since that film is what they’re breeding in.
For extra cleaning power you can add a capful of bleach to flush the drain (which also clears buildup) — or, as a bleach-free alternative, pour in half a cup of baking soda followed by a cup of white vinegar, let it fizz for about 30 minutes, then flush with boiling water. Use one method or the other, never both — never combine bleach with vinegar, which produces toxic gas. The boiling-water flush and scrubbing do most of the real work; the baking soda and vinegar mainly help loosen and rinse debris.
Pro Tip: drain flies can signal a moisture or mold problem — see our mold cleaning guide.
IDENTIFYING TYPES OF GNAT |
FUNGUS GNATS |
FRUIT FLIES |
DRAIN FLIES |
Found on houseplants and soil |
X |
||
Found on fruit and sugar |
X |
||
Found near sinks and drains |
X |
||
Most active in daytime |
X |
X |
|
Most active at night |
X |
||
Dark brown/black |
X |
||
Light brown/gray |
X |
X |
|
Hairy/fuzzy bodies |
X |
||
About the size of a pinhead (⅛ inch) |
X |
X |
|
About the size of a pea (¼ inch) |
X |
How to get rid of gnats in the house
Even if you’re not sure which type you have, the universal first step is to remove food sources. Store fruit in the fridge or pantry, toss overripe produce, wipe up spills, and make sure trash cans seal tightly.
Fruit flies and fungus gnats often arrive hidden in things you bring home — a new potted plant or a bag of fruit. It only takes a couple to start an infestation. Drain flies, contrary to belief, don’t come up through drains — they enter from outside and breed in the organic buildup inside, so regular drain cleaning removes what attracts them.
How to get rid of gnats outside
Since most gnats enter from outside, reducing their numbers around the house helps — though you can’t eliminate them entirely outdoors. An easy yard trap: a shallow bowl of apple cider vinegar with a few drops of dish soap. The vinegar attracts them, and the soap makes them sink. Place a few near entry points to catch flies before they get in.
Pro Tip: vinegar is also a great all-purpose cleaner — here’s how to clean with vinegar.
How to get rid of gnats on plants
Small black flies on indoor plants are almost always fungus gnats. Yellow sticky traps catch the adults, but to kill the larvae in the soil, drench it with a mix of one part 3% hydrogen peroxide to four parts water. The peroxide kills larvae on contact and breaks down harmlessly into water and oxygen, so it won’t hurt the plant.
To keep them from coming back, let the soil surface dry out between waterings (fungus gnats need moist soil to breed) and top the soil with diatomaceous earth or a layer of sand. Diatomaceous earth’s fine silica particles are abrasive to insects, and the dry barrier stops adults from reaching the soil to lay eggs. (Some people use cinnamon as a mild antifungal on the surface too.)

How to get rid of gnats in the kitchen
The kitchen attracts gnats most, but it’s also where you least want chemical sprays near food. Prevention works best: wipe up spills (flies love sugar) and crumbs, dry out damp areas around the sink, rinse produce when you bring it home to wash off any eggs, and dry food before storing.
If gnats are already there, use a vinegar-and-dish-soap trap or a commercial fly trap, and look for where they swarm most densely to find and remove the source. With no food available, they leave quickly.
Pro Tip: here’s how to look after granite countertops.
Gnat traps without apple cider vinegar
ACV is the classic bait, but it isn’t the only option. These also work:
- Red wine
- White vinegar (or any vinegar)
- Overripe fruit
- Mashed banana
- Sugar water
Red wine or white vinegar
Pour a little into a glass with a few drops of dish soap — just as effective as ACV, since fruit flies are drawn to the fermentation and acetic acid in both.
Overripe fruit or mashed banana
Put the fruit in a jar or bottle, cover the opening with plastic wrap, and poke a few small holes. Flies crawl in but can’t get out; toss the whole trap when done. Mashed banana ripens fast and works in minutes.

Sugar or honey
Flies are extremely sensitive to sugar. Mix ¼ cup sugar into ½ cup warm water (warm dissolves it faster) with a few drops of dish soap, or use watered-down honey for the same effect.
Why every trap uses dish soap
The soap doesn’t poison the flies — it breaks the liquid’s surface tension. Normally flies can land on liquid without sinking; with soap added, they fall through and drown.
Getting rid of gnats: step by step
Step 1: Remove food sources — overripe fruit, spills, and organic buildup in drains.
Step 2: For drain flies, pour boiling water (and scrub) down drains 2-3 times a week for three weeks.
Step 3: For fungus gnats, drench houseplant soil with a 1:4 hydrogen peroxide and water mix to kill larvae.
Step 4: Let potted-plant soil dry on top, and cover with sand or diatomaceous earth.
Step 5: Use a trap (DIY or commercial) to catch the remaining adults.
That clears all three common gnats — then keep them away with regular cleaning and good habits. If an infestation persists despite all this, a pest-control professional can identify a hidden breeding source.