What Causes Gnats?
Factors that Contribute to a Gnat Infestation
The very similar factors that create suitable gnat habitat are the same for almost all insects – the presence of preferred sources of food, moisture and protection. Therefore, the answer to our question for the gnats examined here are much the same, except for fungus gnats.
Moist Soil - The principle difference with the fungus gnats is the typical breeding and development site being moist soil that promotes plant root and soil fungi growth rather than the organic matter associated with foods, food wastes and products of decomposition and fermentation.
Decomposing Organic Matter - It is important to realize that wastes and sewage from a broken plumbing pipe that enables organic wastes to accumulate in the soil may be the direct cause of moth flies and phorid flies.
In summary, fruit flies, phorid flies and moth flies are caused the attractiveness of moist organic matter, fruits, and vegetables of some sort.