How do you get rid of gnats in the house?
You get rid of gnats in the house by finding where they are breeding and destroying that specific spot. Because these tiny flies can be fruit flies, drain flies, phorid flies, or fungus gnats, the fix depends entirely on matching the insect to its source, such as clearing drain slime or drying out houseplant soil.
What is actually going on
It starts innocently enough. You are rinsing a dish and one tiny fly drifts up from the sink. The next day there are three hovering over the fruit bowl, and by the weekend you are doing that slow clap-in-the-air move over your own kitchen, a move that has never once caught anything. So here is the blunt answer: you get rid of gnats by finding where they are breeding and destroying that spot. That is the whole trick. The flying adults are just symptoms. The real colony, eggs and larvae sitting in something damp and organic, is the disease, and no amount of swatting, spraying or fogging touches it.
This is where most people go wrong, and honestly it is understandable. The hardware store sells you a can of something that promises to kill flying insects, and it does, for about six hours. Then the next generation hatches out of the drain slime or the soggy potting soil and you are back at square one, one can poorer. Bug bombs and contact sprays knock down the adults you can see and leave the nursery untouched. If you remember one thing from this, make it that.
The other complication is that "gnat" is not actually a thing. It is a catch-all word people use for any tiny fly indoors, and it usually means one of four different insects: fruit flies around produce and fermenting liquids, drain flies in the slime inside your plumbing, phorid flies around deep gunk like the residue under the fridge, and fungus gnats in overwatered houseplants. Each one breeds somewhere different, so the fix that worked for your neighbor's fruit flies will do absolutely nothing for your drain flies. Step one is figuring out which one you have, and that takes less effort than you might think.
How to tell for sure
You do not need a magnifying glass for most of this, just a few minutes of watching where they hang out and how they move. Fruit flies are the classic kitchen pest: small, tan or brownish, usually with noticeably red eyes, hovering around the fruit bowl, the wine glass you abandoned last night, the recycling bin full of unrinsed soda cans. If they are orbiting anything sweet or fermenting, that is usually your answer.
Drain flies look like tiny moths. Their wings are broad, fuzzy and held over the body like a little tent, and if you squash one it leaves a powdery smudge. They make short, weak hopping flights and they love bathroom and kitchen sinks, shower drains and floor drains. There is a simple test if you suspect a drain: stretch a strip of clear packing tape, sticky side down, over the drain opening, leaving a small gap so air still moves. Check it after a day or two. Flies stuck to the tape mean that drain is an active nursery.
Fungus gnats look like miniature mosquitoes, slender with long legs, and they rise up in a little cloud when you water or bump a houseplant. If the flies are thickest around your potted plants, the larvae are usually in the soil feeding on fungi in the damp mix. Phorid flies are the sneaky ones: they have a humpbacked look and a weird habit of running fast across the counter before they bother to fly. That scuttling run is the giveaway, and it usually points to something nastier, like grease buildup under appliances, a rotting potato that rolled behind the pantry bin, or in stubborn cases a plumbing leak under the floor.
One more, because it trips people up every winter. If you are finding larger, sluggish flies crawling on sunny windows in January, those are usually cluster flies, and they are a completely different story. They came in during autumn to hibernate in your walls, they do not breed indoors, and they could not care less about your drains or your fruit. Cleaning the kitchen will not help. Sealing exterior gaps in late summer and vacuuming up the ones that wander out is the whole playbook.
What usually comes next
Once you know which fly you have, the plan writes itself: get rid of the breeding material, then clean up the adults left over. Fruit flies first. Go hunting for the source, and be thorough about it. Check the fruit bowl, the bag of onions and potatoes in the dark corner of the pantry, the recycling bin, the drip tray under the fridge, the garbage disposal. Toss anything questionable and scrub the bins with soap and water. One forgotten potato quietly liquefying behind a cabinet can pump out a new generation every week or so, which is exactly how "a few flies" turns into a cloud. Then set a vinegar trap for the stragglers: a small bowl of apple cider vinegar with a drop of dish soap, covered in plastic wrap with a few holes poked in it. Fair warning, that trap only works on fruit flies. Drain flies and fungus gnats will walk right past it, which is actually handy information if you are still not sure what you are dealing with.
For drain flies, put the bleach down. I know it feels productive, and so does boiling water, but both rush straight through the pipe without touching the gelatinous slime coating the walls, and that slime is where the larvae live, snug and protected. You need to physically scrub inside the drain with a stiff pipe brush to break that film up, then follow with a microbial or enzymatic drain cleaner used as the label directs, which digests the leftover gunk over several days. And never pour insecticide down a drain. It does not work, and it is not what the product is for.
Fungus gnats get the cheapest fix of all: stop watering so much. Let the top couple of inches of soil dry out between waterings, empty the saucers under the pots, and the larvae die off on their own. Yellow sticky cards near the soil catch the adults. If the infestation is heavy, a soil drench with Bacillus thuringiensis var. israelensis, usually sold as Bti, targets fly larvae specifically. One catch: the Bt sold for caterpillars on garden plants is a different strain and does nothing here, so read the label before you buy.
See the pattern? Every one of these fixes is some version of "find the damp, dirty spot and clean it." Not glamorous, and nobody will ever sell it to you in an aerosol can, but it is the only approach that actually ends the problem instead of pausing it.
When to get help
Most gnat problems surrender to a week or two of cleaning and drying. Some do not, and the stubborn ones are telling you something. If you have scrubbed every drain and the phorid or drain flies keep coming back, especially around basement floor cracks or lower walls, you may have a broken sewer line or a leaking pipe under the slab. That is not a pest problem anymore. It is a plumbing problem, and finding it takes a licensed plumber or pest professional with the right inspection tools.
If anyone in the house is actually getting bitten, stop and rethink the whole identification. Fruit flies, drain flies and fungus gnats do not bite. Painful bites from tiny flies point to biting midges or similar insects that breed outdoors and slip through screens, and that is a different conversation entirely. For any skin reaction that is spreading, severe or worrying, see a clinician rather than guessing at a cause from the internet, and call poison control if anyone has a bad reaction to a pesticide.
If you are facing overwhelming numbers in a commercial kitchen, a healthcare setting, or a home where someone has asthma or allergies that seem aggravated by the flies, bring in a licensed pest control professional. Otherwise, give the boring method a fair shot first: find the damp, dirty spot, clean it out, and let the adults die off. It is not glamorous, but it works, which is more than the bug bomb can say.