Allowing houseplants to dry before watering them again helps to get rid of fungus gnats. This kills the fungus in the soil that attracts the gnats. Identifying the type of gnat is key to effective control.
Fungus gnats lay their eggs in the soil of houseplants that receive too much water. The immature insects attack the root hairs of the plant. These insects often kill young plants and are sometimes responsible for the death of larger plants that are already unhealthy. Letting the soil dry and killing the fungus affects its life cycle. A vacuum cleaner hose captures adult fungus gnats.
Fruit flies are another type of insect some people call gnats. Overripe fruit attracts these insects, so moving ripe fruit to the refrigerator for storage helps to keep them under control. Electronic fly exploders can help to reduce fruit fly populations outside of the home, but are also dangerous for other helpful insects. Indoors, ultraviolet traps with sticky boards help to trap the flies. Swatting is another way of controlling gnats, but the small insects are often difficult to hit. Large gnat populations sometimes require the help of an exterminator.
Phorid flies or sewer gnats reproduce in areas where there are open or broken sewer lines. If these gnats appear, the best way to get rid of them is by repairing the sewer line or septic tank.