Fungus gnats are the small dark flies that rise off the soil when you water. The flying adults are the stage people see and attack, and they are the stage that does not matter.

Why sticky traps alone fail
Adults live about a week. In that week a female lays a few hundred eggs in damp soil. The larvae hatch, feed on fungi and organic matter in the top few centimetres, and emerge as the next generation.
So killing adults removes this week's flies and none of next week's. That is exactly the pattern people describe: traps work for a few days, then the gnats are back.
The larvae are in the soil, and the soil is where treatment has to happen.
The one change that matters most
Fungus gnat larvae need moist soil in the top layer. Let that layer dry, and the eggs and young larvae do not survive.

Water thoroughly, then wait until the top two to three centimetres are properly dry before watering again. For most houseplants that is fine; for a few moisture-lovers it is not, and those need one of the treatments below instead.
Bottom watering helps for the same reason: the surface stays dry while the roots still drink.
Treatments that reach the larvae
Bacillus thuringiensis israelensis (Bti). A soil bacterium sold as mosquito bits or granules. It kills gnat larvae specifically and is harmless to the plant. Steep it in water and use that water for a few consecutive waterings. This is the most reliable option.
Hydrogen peroxide. Common advice, and it does work on contact — roughly one part 3% peroxide to four parts water, used as a normal watering. It kills larvae it touches and then breaks down into water and oxygen.
Two caveats worth knowing before using it: it kills only what it reaches on that watering, so it must be repeated, and stronger concentrations damage roots. It is a knockdown, not a cycle-breaker.
Sand or grit topping. A layer of coarse sand or fine gravel on the surface makes it hard for adults to reach the soil to lay. Effective as prevention alongside drying out.
Sticky traps. Worth using — not to control the population but to measure it. Fewer flies caught week on week tells you the soil treatment is working.
Where they came from
Almost always in bagged compost or on a newly bought plant. A shop plant that has been watered daily on a bench is a likely source, which is why quarantining new plants for a fortnight is worth the trouble.
They can also breed in a forgotten saucer of standing water, or in the soil of a plant that gets watered on a schedule regardless of need.
What they do to the plant
Adults do nothing. Larvae feed mainly on fungi and decaying matter, but in heavy infestations they graze on fine root hairs, which sets back seedlings and cuttings noticeably. A mature plant in a big pot usually shrugs them off.
So the urgency depends on what you are growing. Seedlings — act quickly. An established monstera — annoying rather than dangerous.
Expect three weeks
The full cycle from egg to adult runs a few weeks depending on temperature. Any treatment needs to run at least that long to catch every stage, and stopping when the flies disappear is how the infestation returns.
Telling them apart from other small flies
Not every small fly around plants is a fungus gnat, and the treatments differ.
Fungus gnats are dark, slender, long-legged, and fly weakly in short erratic hops close to the soil. They come off the pot when you water.
Fruit flies are rounder, tan or brown, often with red eyes, and hover around fruit bowls and bins rather than soil. Soil treatment does nothing for them.
Shore flies look stockier and darker with pale spots on the wings, and they also breed in wet growing media — the soil treatments above work on them too.
If the flies are around the kitchen rather than the plants, and the plant soil is dry, the problem is probably not in the pots at all.
Prevention costs nothing
Quarantine new plants away from the collection for a couple of weeks. Empty saucers rather than leaving standing water. Store bagged compost sealed and dry. And let pots dry between waterings as a habit rather than as a treatment — the same change that clears an infestation prevents the next one.
