No one wants moths flying around them. Not only are moths irritating and unappealing, they can also spread germs making them a health hazard to humans.
Many people will not consider having a compost bin because of how flies are commonly associated with compost piles.
The reason compost piles attract flies is simple; compost piles are a great source of food for flies and provide the ideal breeding habitat for them (this is why you will see maggots in your compost pile, too).
Just because you have a compost pile does not mean you have to deal with flies.
For the Most Part – Fly infestations occur with compost piles that have not been properly managed. In this article we will discuss ways that you can eliminate flies and, at the very least, prevent flies from infesting your compost pile.
Why Do Flies Invade Compost Bins?

Flies are decomposers, meaning they decompose organic matter to their basic organic structures.
Compost heaps comprise organic material like kitchen waste, vegetable and fruit waste.
Therefore, flies will break this down, which is to our scientific benefit.
Also, the compost bin attracts flies because it naturally contains food for flies.
These life forms will feed on overripe fruit and decayed organic matter. There is plenty of this type of material in compost bins.
Additionally, flies are attracted to warm, acidic, and smelly conditions. All possible within the compost bin.
Humorously – A compost pile is the best breeding spot for flies. Flies will lay their eggs on the compost and the larvae or maggots live under the material until they are fully grown.
The young larvae have an adequate food source to live on, until they become adults.
A fly lays thousands of eggs and their life cycle is only about 10 days. Therefore they reproduce very fast.
The microclimate inside a compost bin is ideal for flies to live.
Flies that are evident around your compost bin could include fruit flies, houseflies, vinegar flies, and soldier flies.
Ways To Get Rid of Flies In Compost Bins
Here are suggestions for minimizing or eliminating flies in and around your compost bin.
Manage Your Compost Bin Properly

Proper management of your compost bin is a key way to eliminate flies.
As discussed above, flies usually arrive when compost bins are not managed well and are improperly kept.
To start, you need to be mindful and pay close attention to how you dispose of your waste- disposing of waste in any old way is a disaster waiting to happen.
You should be burying the green and/ or moist waste under green waste and or a layer of soil or dry brown materials.
Basically, you need to create a barrier to prevent flies from accessing the green waste.
Remember, Proper management of a compost bin also means regularly turning the pile to give air circulation.
A properly oxygenated pile has a slower decay rate and is less smelly, which discourages flies.
If you can turn and rake the pile daily, the better. The larvae will die off, and the flies will find somewhere else to house.
It helps also to keep the pile level and not too concentrated in the middle.
When it is too concentrated in the middle, that is the warm and moist area of compost, which is ideal for fly and pests. If the pile is leveled, it cools the compost down, which also discourages flies.
Raise The Ph Level of The Pile
Flies thrive in acidic conditions, like a compost bin with rotting fruits and kitchen scraps.
Thus, to avoid flies from invading the bin, raising the pH of the fill will help.
One way of increasing pH is aerating and mixing that fill to add oxygen, thereby lowering the acidity.
Another way would be to add more alkaline items such as lime fertilizer, wood ashes, or baking soda.
Add More Brown Material in The Compost Bin
Brown material applies to dry items that do not break down easily, including:
- paper bags
- leaf litter
- and newspapers
By adding brown material to your compost, you allow it to dry out, thereby slowing disintegration.
This will ultimately force flies away and away from invading.
The rule of the thumb would be to apply brown material for every two parts of green waste. Think about it. A ratio of 2:1.
Since flies do not really like brown material, it is most likely better to keep that as the top material layer.
It will also force any green waste deep into the bin where flies will have trouble accessing.
Heads Up! With the green waste, it is advisable to take brown waste with you to cover the green waste.
Move The Compost Bin to Direct Sunlight
Flies and their maggots flourish in moist environments.
Placing your compost bin in direct sunlight dries it out, and in the heat, eggs and larvae are killed.
This way you can eliminate the next generation of flies.
The flies buzzing around your bin will eventually be reduced by a factor of a million.
Start A New Pile of Waste
When a fly infestation is terrible, don’t add to it.
Adding to it means adding food and one of the worst things you can do to keep from having more and more flies.
In this case, the best thing to do is to let it rest and start a new pile.
If you have to dump something, dump brown instead. And, if possible, you can also turn and rake the pile to aerate it.
Freeze Kitchen Waste Before Dumping into The Bin

Flies tend to be attracted to warm areas. Freezing fruit and vegetable scraps that you are about ready to discard keeps the flies from coming around.
Place kitchen matter in plastic bags and put them in the refrigerator overnight, and the following day you dump them in the bin.
Cold gets rid of the eggs hidden in the wholes and in doing so prevents a whole generation of flies from hatching.
Use of Traps
For centuries traps have been a way to manage pests or unwanted animals.
There are a variety of methods to trap persistent flies and reduce nearby compost pile activity.
The methods can be categorized into three general types of traps – vinegar traps, food traps, and adhesive fly traps.
Vinegar Trap Method

Flies are attracted to vinegar.
Thus, place some apple cider vinegar in a bowl not too far from your compost pile.
Next, (or simultaneously) strategically place a drop of scented dish soap near the vinegar bowl so that a fly will touch the soap before touching the vinegar bowl.
The soap or detergent breaks the vinegar surface tension, so when the fly tries to drink the vinegar, it sinks below the surface tension.
Because of the liquid’s surface tension that broke, the fly will not be able to escape.
Food Trap Method
Certain foods, like banana peels and wine, are well-known for attracting flies.
This is what makes them great baits. Place banana peels in one container and wine in another container. Cover them with saran wrap (or something similar) and poke holes in the wrap.
Flies will swarm to the containers, find the holes, and get in. Once they are inside, they will be trapped and unable to escape.
Adhesive fly trap Method
Flies are drawn to the adhesive, and this makes it a great trap.
Simply put the adhesive near the bin with the food waste that attracts the flies.
Flies will travel to the adhesive and get stuck to it.
Although this type of trapping might not remove all the flies, it will most likely take a number of flies out.
Preventing Flies from Getting into Your Compost Bin
If your bin has not yet been colonized by flies, you may want to take some preemptive measures.
One way to help your bin is to keep ‘eatables’ away from the bin.
By eatables, I mean any food that may attract flies like:
- fruit peels,
- leftovers,
- and vegetables.
It helps to keep those items away to limit any readily available attractions for flies.
Also, try to get rid of these items quickly and in the proper way (for instance, in garbage bags). Do not leave these items laying on the counter or table to sit/reek. Flies are quick, so act quickly.
Appropriate disposal might even mean covering waste or food waste with brown material immediately after being removed from the counter.
Cover your bin to keep flies from accessing waste.
Lastly, this may be similar to a previous comment concerning freezing – consider freezing kitchen waste before disposing it. The latter freezes food to limit reproduction and encourage flies to avoid it, as they often prefer warmer surfaces.
Final Thoughts
Flies are an annoyance and can also be disgusting.
Generally, they are great decomposers but can be unwelcome guests under certain conditions. Compost bins are very nice since they provide flies with an ideal place to live and reproduce.
There are solutions to limit or eliminate flies, especially in an infestation.
As discussed in this piece, good compost bin management, pH, and freezing leftovers to throw into the compost are ways to limit flies in a compost bin.