Getting rid of fruit flies and gnats requires two things: killing the adults you can see and eliminating the breeding sites you probably can’t. Traps alone won’t solve the problem because these insects lay up to 100 eggs per day and can go from egg to reproductive adult in as little as 7 days. You need to cut off the source while trapping what’s already flying around.
Before you start, it helps to know exactly what you’re dealing with, because fruit flies and fungus gnats breed in completely different places, and treating the wrong spot wastes your time.
Identify What’s Flying Around
Fruit flies and fungus gnats are both about 1/8 inch long, but they look and behave differently. Fruit flies are tan or brownish with distinctive red eyes, and they hover around kitchens, trash cans, and anywhere food is ripening or rotting. They’re strong fliers and attracted to light.
Fungus gnats are grayish-black, more mosquito-shaped, and tend to hang around houseplants. Their larvae are tiny white maggots with dark heads that live in the top layers of potting soil, feeding on fungi and organic matter. If you see small flies rising from a potted plant when you water it, those are fungus gnats.
You might also have drain flies, which look fuzzy and moth-like and tend to rest on walls near sinks. They breed in the slimy organic film that builds up inside drain pipes. All three pests require different treatment at the source, so take a moment to watch where the insects are congregating before you act.
Remove Breeding Sites First
No trap or spray will keep up with insects that reproduce this fast if the breeding source stays active. For fruit flies, that means finding and removing every bit of fermenting organic material in your home. The obvious culprits are bananas on the counter and overripe tomatoes, but fruit flies also breed in places people overlook: the gunk inside garbage disposals, residue in recycling bins and unwashed cans, forgotten potatoes in the pantry, damp mops and dishcloths, pet food bowls, and even old lunch boxes.
Go through your kitchen methodically. Move all ripening produce into the refrigerator or into sealed containers. Empty and clean your trash can, not just the bag but the can itself. Rinse every recyclable before it goes in the bin. Wring out sponges, mops, and dish towels and let them dry completely. Check under the sink and behind appliances for any forgotten food residue. Removing the breeding source is the only permanent fix.
For fungus gnats, the breeding site is overwatered houseplant soil. Females lay 100 to 150 eggs in moist potting mix. The single most effective step is to let the top inch or two of soil dry out completely between waterings. This kills larvae and makes the soil inhospitable for egg-laying. For plants that need consistent moisture, consider bottom-watering (setting the pot in a tray of water and letting soil absorb from below) so the surface stays dry.
Build a Vinegar Trap for Fruit Flies
While you clean up breeding sites, set out traps to catch the adults already flying around. The simplest and most effective DIY option is an apple cider vinegar trap. Pour about half an inch of apple cider vinegar into a jar or small bowl, then add two or three drops of dish soap. The vinegar smells irresistibly sweet to fruit flies, drawing them in. The dish soap breaks the surface tension of the liquid so the flies can’t land on it. Instead, their wings get weighed down and they sink.
Place traps near the areas where you see the most activity: next to the fruit bowl, by the sink, near the trash can. Replace the vinegar every two to three days as it loses its potency. You can also stretch plastic wrap over the top of the jar and poke a few small holes in it. Flies crawl in but have trouble finding their way back out.
These traps work well for fruit flies specifically. Fungus gnats aren’t as attracted to vinegar, so if gnats are your problem, use yellow sticky traps placed near the soil surface of your houseplants. The gnats are drawn to the yellow color and get stuck on contact.
Treat Houseplant Soil for Gnat Larvae
Sticky traps catch adult gnats, but the larvae in the soil keep producing new ones. You have two good options for killing larvae directly without harming your plants.
The first is a hydrogen peroxide drench. Mix one part 3% hydrogen peroxide (the standard concentration sold at drugstores) with four parts water and pour it over the soil as you would normally water. It fizzes on contact with organic matter, killing larvae in the top layers. It breaks down into water and oxygen, so it won’t damage roots.
The second option is a biological larvicide that contains a naturally occurring soil bacterium (sold as Mosquito Bits or similar products at garden centers). You dissolve or sprinkle it into the soil and water it in so it filters down to where the larvae feed. It kills larvae but doesn’t affect eggs, pupae, or adults, so you need to apply it every five to seven days for several rounds to catch each new generation as it hatches. This is the method most recommended by university extension programs for persistent infestations.
Clean Your Drains
Both fruit flies and drain flies lay eggs in the organic film that coats the inside of kitchen and bathroom drain pipes. If you notice flies hovering near a sink or shower drain, that buildup is likely a breeding site.
Start by physically cleaning the drain. Remove the drain cover, use a stiff brush or pipe brush to scrub inside the pipe as far as you can reach, and flush with boiling water. For ongoing maintenance, enzymatic drain cleaners use live bacterial cultures to break down the oils, grease, and organic matter that accumulate inside pipes. Unlike chemical drain cleaners, they’re safe for all pipe types and work by digesting the material that flies need to breed in. Use them regularly (weekly or biweekly) until the problem clears, then monthly to prevent re-infestation.
Pouring bleach down a drain can kill larvae on contact, but it doesn’t remove the organic film. The slime reforms quickly, and the flies return. Enzymatic cleaners or manual scrubbing address the actual problem.
Use Sprays as a Last Resort
If you’ve addressed breeding sites and set traps but still have a swarm, a contact spray can knock down the remaining adults. Products containing pyrethrins (a plant-derived insecticide) kill fruit flies and gnats on contact but break down quickly, so you may need to reapply every couple of days. Insecticidal soap sprays also work on contact for adults near houseplants.
For longer-lasting control, sprays containing synthetic pyrethroids can kill adults for up to three days after application. These are more persistent but also more potent, so always read the product label for instructions on indoor use, ventilation, and whether the product is safe around food preparation areas.
Sprays treat the symptom, not the cause. If you skip sanitation and go straight to insecticides, you’ll be spraying indefinitely.
Prevent Them From Coming Back
Once you’ve cleared an infestation, a few habits keep it from returning. Store all ripe fruit in the refrigerator or in sealed containers, especially during warm months when fruit fly life cycles accelerate to as fast as 7 to 10 days. Rinse produce when you bring it home, since fruit fly eggs can hitchhike in from the grocery store. Take out kitchen trash daily, and rinse recyclables before they go in the bin.
For houseplants, avoid overwatering. Stick your finger an inch into the soil before adding water. If it’s still damp, wait. Adding a half-inch layer of sand or decorative gravel on top of the potting mix can deter fungus gnats from laying eggs, since they need access to moist organic soil. When repotting, use fresh, sterile potting mix rather than reusing old soil that may already harbor eggs or larvae.
Keep drains flowing and clean. A quick flush of boiling water once a week, or a monthly dose of enzymatic cleaner, prevents the organic buildup that attracts breeding flies. Wring out mops, sponges, and kitchen towels after use and let them dry fully. Any moist surface with organic residue is a potential nursery for the next generation.