Where do they come from?

It's possible for them to come into your kitchen on fresh fruit and vegetables from the supermarket. But it's more likely they're drawn indoors by the fragrance of overripe fruits or vegetables on your counter. Fruit flies are attracted to the yeasty aroma that develops as produce ferments, and most supermarket produce is sold before peak ripeness. Other items besides produce, such as beer bottles or the residue in an unwashed recycling bin, also can be a draw.

The flies lay their eggs on the surface of fermenting food, where the larvae can feed after they hatch. They reproduce quickly and can lay hundreds of eggs in their brief lifespan.

To avoid an infestation, refrigerate produce as soon as it's ripe and remove any rotting pieces so the rest won't become infested.

If fruit flies appear, you can easily trap them: Put a little ripe fruit, wine or cider vinegar in the bottom of a bottle, and insert a paper funnel in the neck of the bottle.