Most homeowners have had to struggle with indoor flies at one time or another. Several types of flies can invade your home. Most of the large ones are easily recognizable as blow or common houseflies. Smaller flies inside the home are usually attracted to decaying food or plant materials, according to the University of Nebraska Extension website.
Little flies are usually attracted by garbage, decaying organic matter and general debris. For these reasons, they are sometimes called "filth" files. This does not mean they are found only in dirty or cluttered homes, however. Flies can invade the neatest and cleanest of homes. A single overripe banana, for example, can be the start of a fruit fly infestation. Over-watering a plant creates the perfect soggy soil conditions for fungus gnats to multiply and thrive. Luckily, the flies themselves are usually not harmful to humans, but they can be quite a nuisance.
Fruit flies (Drosophila spp.) are usually found around rotting fruit, which is their preferred location for laying eggs. They will also cluster around garbage and plants. The bodies of these insects are about 1/8 inch and tan in color. Phorid flies (Phoridae) are very similar to fruit flies and cluster in the same areas. They can be slightly smaller than fruit flies and have darker bodies. They also seem to "hop" rather than fly. Fungus gnats (Mycetophilidae and Sciaridae) look like tiny mosquitoes and swarm around wet organic matter, such as overly wet soil in a houseplant.
Yellow sticky traps, which are available at any garden center, can be used to trap the flying adult insects. Throw out any rotting food and take out any odoriferous garbage that may be in your home, as both may contain eggs. Take out recycling as well -- flies will be attracted to the sticky-sweet residue left in soda cans. Drench the soil of plants infested with fungus gnats with an insecticide. You can also use an insecticide spray, but this will pollute the air in your home and any food nearby. For that reason, it's best not to use chemicals unless absolutely necessary. Instead, consider a bait or trap.
Prevention is really the key to controlling flies in your house. First, make sure all of your windows and doors are screened, as well as other entrances to your home, such as drain pipes. Let the top layer of soil on houseplants dry to the touch (about an inch or two down) before watering the plants again. Never let fruit rot in your kitchen, and keep your garbage and recycling areas clean and free of odors.