How to Get Rid of Fungus Gnats on Indoor Vegetables (2026)

Tiny black flies circling your pots? Every time you water, a little cloud of them rises from the soil? Those are almost certainly fungus gnats, one of the most common pests when you grow vegetables indoors.
The good news: fungus gnats are easy to control once you understand what they need. In this guide, I’ll show you how to recognise them, why they appear, and exactly how to get rid of fungus gnats step by step, without harsh sprays near your food.
I’ve had fungus gnats myself, in a pot of spinach. So if you’ve spotted them around your plants too, don’t worry: you’re not alone, and they can be fixed.
What Are Fungus Gnats?
Fungus gnats are small, dark, delicate flies, a few millimetres long, with long legs and thin wings. They are weak fliers, so you’ll usually see them walking on the soil or making short, zig-zag flights around your plants.
They don’t bite and they don’t harm people. The adults are mainly a nuisance. The real problem is their larvae: tiny, clear-to-white worms with shiny black heads that live in the top layer of moist potting mix.

Fungus Gnats or Fruit Flies?
| Fungus gnats | Fruit flies | |
|---|---|---|
| Where you see them | Around pots and on the soil | Around fruit bowls, bins and the sink |
| Look | Dark, thin, long legs, like tiny mosquitoes | Tan or brown, rounder, often with red eyes |
| Flying | Weak, short flights near plants | Faster, hover around food |
Are Fungus Gnats Harmful to Indoor Vegetables?
A few gnats are mostly harmless. But when there are lots of them, the larvae can feed on fine roots and young stems. That matters most for seedlings and young plants, which can wilt, stop growing or collapse. Larger, established plants usually cope better.
Why Do Fungus Gnats Appear?
Fungus gnats lay their eggs in damp potting mix that is rich in organic matter. The main causes are:
- Overwatering: Soil that never dries out is perfect for them. This is the number one cause.
- Water sitting in saucers or pots without drainage holes.
- Heavy, poorly draining potting mix that stays wet for a long time.
- Bringing them in with a new plant or an open bag of potting mix.
How to Check for Fungus Gnat Larvae
Here’s a simple test: press a slice of raw potato lightly onto the soil surface. After a few days, lift it and look underneath. If you see tiny white larvae on the potato or soil, you have fungus gnats breeding in that pot.

Yellow sticky traps are another easy way to check. Stick one in each pot and see which plants catch the most gnats.
How to Get Rid of Fungus Gnats: Step by Step
The trick is to break their life cycle by dealing with both the flying adults and the larvae in the soil. Do all of these together for the best results.
Step 1: Let the Soil Dry Out
Let the top 2.5–5 cm (1–2 inches) of potting mix dry out before you water again. Push your finger into the soil to check. The larvae live in the moist top layer, so drying it out makes the pot much less welcoming.

Your plants still need water. Water thoroughly when it’s time, then let the top dry again. Don’t let plants wilt badly.
Step 2: Water From Below
Pour water into the saucer or tray and let the pot soak it up for 10–15 minutes, then tip out what’s left. This keeps the soil surface drier. It’s the same method I recommend in my guide on how to grow microgreens indoors.

Step 3: Empty Saucers and Improve Drainage
Never leave pots standing in water. Make sure every container has drainage holes. If your mix stays soggy for days, it may be too heavy. My guide to the best soil mix for indoor vegetable containers explains what a good, free-draining mix looks like.
Step 4: Catch the Adults With Yellow Sticky Traps
Fungus gnats are attracted to the colour yellow. Place small yellow sticky traps just above the soil in affected pots. Traps catch the adults before they lay more eggs, but they won’t solve the problem alone, because the larvae are still in the soil. Replace traps when they’re full.
Step 5: Treat the Larvae With BTI
BTI (Bacillus thuringiensis subsp. israelensis) is a natural soil bacterium that kills fungus gnat larvae. It’s sold for home use, often as “mosquito bits” or “mosquito dunks”, or as gnat-specific products.
Usually, you soak the product in water and use that water on your plants. BTI breaks down quickly, so you’ll need to repeat it a few times. Always follow the instructions on the label, and check that the product is suitable for use on edible plants.
Step 6: Repot Badly Infested Plants
If one pot is full of larvae and nothing is working, repot the plant into fresh potting mix and a clean container. Throw the old mix outside or in the compost, not back into another pot.
How Long Does It Take to Get Rid of Fungus Gnats?
Expect it to take a few weeks. Eggs and larvae already in the soil will keep turning into adults for a while, so you may still see some gnats after you start. Keep going with drier soil, traps and BTI, and the numbers should drop steadily.
How to Prevent Fungus Gnats
- Water only when the top of the soil is dry.
- Use pots with drainage holes and empty saucers after watering.
- Use a light, free-draining potting mix.
- Keep potting mix bags tightly closed.
- Check new plants and keep them apart from your other plants for a week or two.
- Remove fallen leaves and plant debris from the soil surface.
- Keep a yellow sticky trap in your growing area as an early warning.
Frequently Asked Questions
Do fungus gnats bite?
No. Fungus gnats don’t bite people or pets. They’re a nuisance, but not a health risk.
Can I eat vegetables from a pot that had fungus gnats?
Yes. Fungus gnats live in the soil, not in your vegetables. Wash your harvest as usual. If you use any product, follow its label for edible plants.
Does a layer of sand on top of the soil help?
Some growers add a thin layer of sand or fine grit on top so the surface dries faster, which can make it less appealing for egg-laying. It may help, but it works best together with careful watering.
Why do I still see gnats after a week?
That’s normal. Larvae already in the soil are still growing into adults. Keep the soil drier, keep the traps up and repeat BTI as directed.
Fungus Gnats Are Annoying, but Easy to Beat
Fungus gnats are a sign that the soil is staying too wet. Let the top dry out, water from below, trap the adults and treat the larvae, and within a few weeks your indoor vegetables should be gnat-free.

For more research-based advice, see the guide to fungus gnats from the University of California Statewide IPM Program.
You may also like: how to fix leggy seedlings, how to grow lettuce indoors and the best vegetables to grow indoors for beginners.
