Gnats may enter the home when food, such as ripe fruit or fungus, is present. Gnats often live in warm, humid environments, such as behind tubs and in drain the pipes of bathrooms.
Both fruit flies and fungus gnats are typically present in infested areas, and both species are often attracted by the same things. For instance, houseplants that have been over-watered may develop root rot, which attracts both gnats and fruit flies.
Gnats may also live in the drain pipes of the tub and sinks in the home. Pour a small amount of oil, such as vegetable oil, into the drains to eliminate the pests. Gnats may enter the bathroom from other areas in the home when a food source is present. For instance, ripened fruit may attract the pests to the kitchen, and the insects enter the bathroom in search of water. Throw out any unrefrigerated foods that are too ripe for consumption to reduce the pests in the home.
Fungus growth attracts gnats, and may be caused by hidden water leaks in the home. Check around the tub to determine whether the caulking is secure, and make repairs as needed. For instance, if a damaged strip of caulking has allowed water to leak into the insulation behind the tub, the insulation in that area may be mildewed or moldy. Removing and replacing the damaged insulation is an effective way to eliminate gnats that are attracted by fungus.