How to Prevent Fruit Flies

13 Ways to Prevent a Fruit Fly Infestation

Fruit flies on an orange

The Spruce / Meg MacDonald

If you like to have fresh fruits and vegetables in your house, then you have probably encountered a tiny pest that likes them as well: the fruit fly (Drosophila melanogaster). Of course, there's seldom just one fruit fly, because these pests breed and reproduce so quickly.

That's great for scientists doing genetic research, because the fruit fly's life cycle can be as short as only eight days. But it's not so much fun when flies are buzzing around your kitchen.

While the flies don't sting or bite, they can cause foodborne illness by spreading bacteria from contaminated foods to other surfaces in the home. Research has shown that fruit flies are a significant vector in the spread of E. coli.

Once you have a fruit fly infestation, you'll want to eliminate them as quickly as possible (possibly with a homemade fruit fly trap). But, there are steps you can take to prevent an infestation of fruit flies from becoming a bigger problem.

  1. Repel Fruit Flies With Herbs

    An effective way to keep fruit flies out of your kitchen is to place certain scented herbs around the room or add a few drops of essential oils to a diffuser. Try using lavender, mint, rosemary, basil, eucalyptus, clove, or lemongrass.

    Fresh herbs and oil in kitchen

    Getty Images / Stefan Tomic

  2. Know What Fruit Flies Love

    Fruit flies are drawn to anything containing sugar that ferments into alcohol—such as overly ripe fruit, beer, or wine, to name a few common items. If they can't readily find their very favorite foods, they will search it out in sticky garbage cans, compost bins, sink drains, and recycling bins. Doing some routine housekeeping chores can help solve the problem!

    A glass of wine left on the countertop

    The Spruce / Meg MacDonald

  3. Wash and Inspect Produce

    When you bring home produce from the market, carefully inspect it for any bruising or damage. Wash the produce well before using or storing it to remove fruit fly eggs or larvae that may have hitched a ride.

    Rinsing off produce

    The Spruce / Meg MacDonald

  4. Store Fruit and Produce Properly

    While a bowl of fruit on a counter is lovely and easy to access, it is best to store fruits in the refrigerator to slow the ripening process and prevent the attraction of fruit flies. Only place uncovered fruit that will be consumed within a few hours on the counter.

    Storing fruit and produce properly

    The Spruce / Meg MacDonald

  5. Dispose of Damaged Fruit Correctly

    Once fruit and vegetables become overly ripe or damaged, tossing them in a kitchen waste bin will still attract fruit flies. Instead, place the rotten fruit or peelings in a covered compost bin, outdoor compost pile, or place in a sealed bag in an outdoor waste container.

    Correctly disposing of fruit

    The Spruce / Meg MacDonald

  6. Clean Food Preparation Areas Promptly

    Fruit flies can find that tiny piece of fruit or drops of spilled wine very quickly. Prompt and thorough cleaning of counters, tables, small appliances, and dishes after any type of food preparation or service will help prevent an infestation.

    One key area to clean well is the kitchen sink and garbage disposal. Bits of food can become trapped in the drains. Clean and flush out drains and disposals well after each use for food preparation.

    Cleaning food prep areas

    The Spruce / Meg MacDonald

  7. Wash Sponges and Dishcloths Frequently

    When you finish cleaning up the kitchen, there are probably bits of food trapped in the sponge, brush, dishcloth, or mop you used. Don't leave a sticky cleaning tool lying around to attract fruit flies. Toss the items into the washer or dishwasher instead.

    Placing used brushes and sponges into the dishwasher

    The Spruce / Meg MacDonald

  8. Keep Windows and Doors Closed

    Fruit flies are so tiny that they can slip through window and door screens. Keep doors and windows closed as a better deterrent.

    Keeping windows closed

    The Spruce / Meg MacDonald

  9. Control Indoor Humidity

    Keeping indoor humidity rates low slows the deterioration of fruit. Use a dehumidifier and air conditioner to help keep humidity as low as possible.

    Person controlling the thermostat

    The Spruce / Meg MacDonald

  10. Blow Them Away

    If you are working with lots of produce during a marathon meal preparation or food preservation session, put an oscillating fan in the kitchen to keep the air moving. This will help prevent the flies from landing on the foods to lay eggs and shorten the cycle of the infestation.

    Using a fan during meal prep

    The Spruce / Meg MacDonald

  11. Check the Pantry

    There's no fruit on the counter but you still have flies. Why? It could be something rotting in the pantry. Fruit flies like mushy potatoes and onions just as much as bananas.

    Wiping down the pantry to make sure there are no fruit flies lingering

    The Spruce / Meg MacDonald

  12. Pay Attention to Your Trash Can

    While you can have an outbreak of fruit flies during any season, summer is a key time, because of the abundance of produce and the added heat and humidity. If there's lots of eating going on, it is worth your time to empty the trash can twice a day to an outdoor container. The trash can should also be washed out with an all-purpose cleaner or dishwashing liquid and water at least weekly to remove any seepage and stickiness in the bottom that can attract fruit flies.

    Rinsing out the trash can

    The Spruce / Meg MacDonald

  13. Rinse out Recyclables

    If you have a bin for recyclables, be sure to rinse out bottles and cans before you toss them in the bin. A few drops of beer, wine, or soft drink is ambrosia to a fruit fly. Use this tip even if the bin is outside. Fruit flies like to sneak into your kitchen every time a door is opened, so empty the bins often and give indoor and outdoor bins frequent cleanings to eliminate food sources for fruit flies.

    Rinsing out recycling cans

    The Spruce / Meg MacDonald

The Spruce uses only high-quality sources, including peer-reviewed studies, to support the facts within our articles. Read our editorial process to learn more about how we fact-check and keep our content accurate, reliable, and trustworthy.
  1. Buyukyavuz, Ahmet, et al. Escherichia Coli Transfer to Food by Fruit Flies during Short Time ExposureJournal of Food Research, vol. 7, no. 4, 2018, p. 131., doi:10.5539/jfr.v7n4p131