Flies in Compost and What to Do About Them

This post may contain affiliate sales links. Please see my full disclosure policy for details

When I mention the word “flies,” what does it bring to mind?

A rolled-up newspaper?  Roadkill?  Garbage?  Filth?  Maggots?

If you’re like most people, nothing good comes from that little word association save for, maybe, the idea of swatting them from the air and killing them. However, did you know that they may not be quite as filthy as you have imagined?

Flies actually clean themselves constantly and some species should be a welcome sight around your compost pile.  Some of them recycle food scraps and return them to the soil in the form of nutrients.

As decomposers, some of them assist the microorganisms in speeding up the process of breaking down organic matter.  They will enrich the soil.

While, they are often unwelcome guests, there are circumstances where certain species should be allowed to shine.  With the right type of fly, your compost pile should be one of those places.

This article will discuss some different species and what their presence signifies.  We will discuss ways that you can control their presence around your compost bins.

Fly infestations frequently take over compost bins.

Different Species

As long as you don’t put meat, fish, or chicken scraps (which is a bad idea anyway), you’re not going to have traditional houseflies buzzing around your piles. 

If you’re composting correctly, you shouldn’t see many flies, but you may see their larvae.  They are a perfect environment for them to lay their eggs.

A small number of them is expected, however, if you see a swarm of them, then you may be doing something wrong.

Here are a few of the different species that you’ll usually see hovering near your bins.

Vinegar Flies

The vinegar fly is a very small species.  It is often confused with the fruit fly, but they are not the same species in the traditional sense. They do not feed on the fruit itself. Instead, they are attracted to the yeasts associated with rotting and fermenting fruit.

They are harmless and their larvae feed on microorganisms.  As the maggots process these microorganisms, they provide food for the bacteria to help with the decomposition process.

vinegar fly sits on a fruit inside of a compost bin


Houseflies (and their maggots) are the species that you want to keep away.  While one or two aren’t that big of a problem, an infestation is something you need to deal with swiftly. These insects carry and spread disease and reproduce extremely fast.

If you’ve encountered a hoard of them, then you have likely put some sort of food waste in your pile that they are attracted to.  Kitchen scraps will attract houseflies to your compost.

Fruit Flies

As referred to earlier, these are very similar to vinegar flies. However, instead of feeding on the yeast of rotting fruit and fermenting fruit juices, they feed directly on the fruit.

Fruit flies are annoying, but they are relatively harmless.  Their maggots also feed on microorganisms in compost and feed the bacteria after processing them.

While they may not be the most beneficial species, they certainly are not the worst insects to have around. 

Soldier Flies

Soldier flies are often mistaken for wasps because they look like they are ready for battle.  However, they do wonders for speeding up the decomposition process (and so do their maggots).

Their maggots are brown and scaly and, without question, look a little off-putting.  That being said, they significantly speed up the process of breaking down organic materials. Furthermore, after they process organic material, they inoculate it with new beneficial bacteria.

Soldier fly maggots also work well in a worm bin.  The worms in the bin won’t eat the larvae and vice-versa.  In fact, a worm bin with a healthy population of soldier fly larvae is one of the better ways to compost. 

A beneficial soldier fly sits on a compost bin

How to Deal with Them

To deal with flies in your pile, turn and rake your pile as frequently as possible, preferably every day. They will eventually move on and their larva will die. Once the fly issue has resolved, maintain your pile by raking about two timer per week. Also try some of our other tips below.

Proper 2:1 Ratio of Material

One of the first things you should try is to add more brown material to the compost. The proper ratio that we talk about is 2 parts of green material for every 1 part of brown material.

By adding more brown material, you help the dry out the pile, which discourage them from inhabiting your bin. As an added benefit, you will also keep the smell down.

Most insects don’t like feeding on brown material so make sure that the topmost layer is covered with brown material and that your green material is always below that.

Just remember one caveat: the more brown material you have, the longer it will take for the decomposition process to be completed.

Tip: Leave some brown material next to or near your pile so that whenever you add more green material, you can top it off with brown material.

Limit Access to Their Food Supply

Whenever you’re putting kitchen scraps into your pile, make sure to push the food scraps down deeper into the pile. This makes it very difficult for the insects to reach their feeding ground.

Some other things you can try is to wrap your kitchen scraps in butcher paper (no waxy paper) or newspaper and add them into your pile in bundles. As you are putting in the bundle (keep it wrapped in the paper) bury it under the surface of the bin.

Try not to add too much pulp material, like citrus, as it will likely attract all sorts of insects. Also consider using banana peels as fruit fly traps (see below) rather than adding them to your pile.

Tip: Line your kitchen waste container with newspaper so when you are ready to bring your scraps out for composting, you can just scrunch up the surrounding newspaper and bring it out as a bundle.

Flies feeding on green organic materials in a compost pile

Raise the pH Level

Raising the pH level will deter flies from invading your compost.

Aerating or mixing your pile will naturally raise the pH of your pile and is highly recommended because it will push the green materials farther from the top.

If you must, you can also add agricultural lime fertilizer to increase the pH level, but this is not recommended because it causes ammonia gas, which causes odors and nitrogen to dissipate which should be kept in the compost for your plants.

Even though it is less effective than Ag lime, you can also add wood ashes or baking soda. For wood ash, simply add about ¼ inch of wood ash and then mix and water the pile. For baking soda, mix a tablespoon of baking soda into a gallon of water and then pour it on the pile and mix.

You’ll want to make sure the pH level is appropriate for use on your plants.

Fruit Fly Traps

Adhesive Fruit Fly Traps

Fruit flies and other invasive fly species are attracted to the adhesive on the fruit fly trap. 

So hang them above or around the area of your compost or worm bins.  This is an easier food source for the bugs to reach and they’ll take an easy meal over one they have to search for.

Food Fruit Fly Traps

You can also use banana peels or wine to distract flies away from your piles.  Put either one in a plastic container and cover it with saran wrap. Poke a few holes in the saran wrap and place it near or the top of your pile. They will fly in for the trap and be unable to escape.

Both of these techniques may not eradicate the problem, but it will keep the number of fruit flies to a reasonable amount. 

Vinegar Fruit Fly Traps

Vinegar traps can be effective in killing fruit flies near compost

Place a fruit bowl filled with apple cider vinegar and a drop of dish soap near your compost.  It will attract flies with its scent.  The vinegar attracts the fruit fly and the detergent affects the vinegar’s surface tension. So when an unassuming fruit fly tries to drink the mixture, it falls into it and is unable to get out.

Change the mixture regularly to keep it effective.

–The Green Pinky

Please help share our content!

About the author: Jeffrey Douglas is a horticultural hobbyist that loves everything related to plants and gardening. He specializes in gardens and houseplants.

Notify of
Inline Feedbacks
View all comments