Gnats are attracted to moisture, decaying organic matter, body secretions, and certain wavelengths of light. The specific attractant depends on the type of gnat, but nearly all species share one thing in common: they’re drawn to damp environments rich in decomposing material. Understanding what pulls them in is the fastest way to figure out why they’re in your home and how to get rid of them.
Moisture and Decaying Organic Matter
The single biggest gnat magnet is wet, decomposing organic material. Fungus gnats, the tiny flies you see hovering around houseplants, lay their eggs in moist soil and potting mix. Their larvae feed on fungi, root hairs, and decaying plant matter in that soil. Organic mulch, leaf mold, grass clippings, compost, and organic fertilizers all serve as favorite breeding spots.
Overwatering is the main trigger for indoor fungus gnat infestations. This is especially common in winter, when plants use less water due to lower light and slower growth. Many people stick to a once-a-week watering schedule year-round, but as the sun weakens in colder months, soil stays wet much longer. That waterlogged soil is exactly the environment fungus gnats love. If you’re seeing small flies around your houseplants between November and March, overwatering is almost certainly the cause.
Fermenting Fruit and Kitchen Scraps
Fruit flies, often lumped in with gnats, zero in on ripening and fermenting produce. The chemical compounds released as fruit breaks down, particularly the acetic acid in fermentation, act as a powerful lure. A single overripe banana on the counter or a few forgotten berries in the back of the fridge can kick off an infestation. Compost bins, recycling containers with residue, and even wine or beer bottles left out overnight all emit the same fermentation signals.
This is why apple cider vinegar works as a trap. Its acetic acid mimics the smell of fermenting fruit. A simple setup of a quarter cup of apple cider vinegar with a teaspoon of sugar, a single drop of dish soap (which breaks the surface tension so the gnats sink instead of landing safely), and plastic wrap with small holes poked in it will pull fruit flies out of the air effectively.
Drains and Plumbing Buildup
Drain flies, sometimes called moth flies, breed in the slimy organic film that coats the inside of sink and shower drains. In homes, bathroom drains are the most common breeding site. In restaurants and commercial kitchens, floor drains, grease traps, mop-drying tubs, and the evaporation pans beneath refrigerators all harbor the same kind of buildup. Drain flies have even been found breeding in elevator pits, around sump pumps, and in material beneath leaking pipes.
The key attractant here isn’t standing water alone. It’s the gelatinous layer of bacteria, fungi, and decomposing organic residue that forms inside pipes over time. Females lay eggs directly into this slime. If you’re seeing tiny dark flies near your sinks but have no overripe fruit or houseplants nearby, your drains are the likely source.
Body Heat, Sweat, and Secretions
Some gnats are attracted directly to you. Eye gnats, common in warm agricultural areas, feed on animal and human sweat, skin oils, and even secretions around the eyes, nose, and mouth. Female eye gnats need the proteins found in these secretions for egg production, which is why they persistently hover around your face and crawl toward your eyes and any open wounds. Carbon dioxide from your breath and body heat also serve as navigational cues that help gnats locate a host from a distance.
If you’ve noticed tiny flies that seem fixated on your face while you’re outdoors, especially in hot weather, you’re likely dealing with eye gnats rather than the fungus gnats or fruit flies common indoors.
Light, Especially UV and Blue Wavelengths
Gnats and other small flies are strongly attracted to certain colors of light. Research published in Frontiers in Ecology and Evolution found that for flies (the order Diptera, which includes gnats), ultraviolet light was overwhelmingly the most attractive wavelength. UV light scored a relative attraction coefficient of 1.000, while blue light (around 478 nm) scored 0.021 and red wavelengths scored essentially zero.
In practical terms, this means gnats are far more drawn to cool-toned, blue-white lights than to warm amber or red-toned bulbs. If you leave a porch light on at night, especially a bright white LED or fluorescent bulb, you’ll pull in more gnats than a warm-colored light would. Switching outdoor lighting to warmer color temperatures (around 3,000 K or lower) or yellow “bug light” bulbs reduces how many flying insects congregate around your doors and windows.
How to Remove What’s Attracting Them
Since gnats follow moisture and decay, the most effective strategy is eliminating those conditions rather than killing individual adults. For houseplant gnats, let the top inch or two of soil dry out completely between waterings. Adjust your watering schedule seasonally, giving plants less water in winter when they need it least. A soil drench made from one part 3% hydrogen peroxide mixed with four parts water will fizz on contact and kill larvae in the soil without harming your plants. Let the soil dry afterward.
For fruit flies, store ripe produce in the refrigerator and clean up spills, crumbs, and residue in recycling bins promptly. For drain flies, physically cleaning the organic buildup inside your drains is more effective than pouring bleach down them, since bleach slides past the slime layer without removing it. A stiff drain brush followed by an enzyme-based drain cleaner breaks down the film where eggs and larvae live.
Sticky yellow traps placed near houseplants catch adult fungus gnats before they can lay more eggs. Yellow is particularly effective because many gnat species use color cues to find plants and flowers. Combining traps with moisture control addresses both the adults already flying around and the larvae developing in soil or drains, breaking the cycle within a week or two.