To control any pest, you need to first identify it and why it is there, then take steps to eliminate it. To control fruit flies (sometimes called gnats), this means first finding the fruit or other organic matter that is attracting them.
Indoor Prevention of Fruit Flies
The only way to completely eliminate fruit flies is to inspect for and get rid of the source. Inspect produce before bringing it into the house, especially if it was purchased at an outdoor market or if any items are over-ripe or beginning to rot. Refrigerating produce will slow the ripening process, but dispose of any items as soon as they become over-ripe or rotten.
In addition to keeping an eye on fruits and vegetables, cleaning should also be a priority. Regularly empty garbage cans and keep this area clean. Clean out drains and disposals to ensure the flies are not harboring or breeding there. Clean up any spills immediately―especially syrupy or sticky spills that will attract flies. Always clean mops well and dry before storing; do not leave wet rags or sponges lying around. If you recycle, rinse these items well and place them in a covered container, preferably outside and away from the home, if possible.
Outdoor Fruit Fly Prevention
If you realize that they are coming in from the outdoors, there are additional sources to inspect and clean.
If you have fruit trees in your yard or the immediate area, these will naturally attract fruit flies. Check for and pick up fruit that has fallen and is beginning to rot. If you use manure to fertilize plants, that can be highly attractive to flies of many species. Keep an eye on this, or switch to another fertilizer method. Also, dog feces in the yard should be promptly picked up as all types of flies are attracted to animal feces.
Check drains around your home for debris. Any outdoor drains that are not regularly cleaned can attract flies and provide an ideal breeding area. Lastly, just as you need to do indoors, keep outdoor trash areas clean, secure the lid tightly, and regularly empty bins.
Get Rid of Fruit Flies
While none of the outdoor items seem particularly difficult, they can be virtually impossible to control if the fruit tree or fertilizer is in your neighbor’s yard, the trash area is a community site, or you live in an apartment or condominium with little or no control over the outside areas.
In these cases, the goal is to keep the outdoor fruit flies from coming indoors and get rid of those that had already gotten in.
Keeping Fruit Flies Out
Fruit flies are so small they can easily fly through the mesh of many door screens. If you normally keep your main doors and windows open in warmer months to allow a breeze through the screens, keep them closed during heavy infestation periods.