Fruit Flies in Your Compost Bin: How to Get Rid of Them for Good

You lift the lid of your compost bin and a cloud of tiny flies comes out. Your first instinct is to give up. Don’t worry: fruit flies in a compost bin are one of the most common problems for apartment composters, and they almost always have a simple fix.

To get rid of fruit flies in your compost bin, cover all fresh scraps with a thick layer of dry material, such as sawdust, dry leaves or shredded cardboard. Place a fine fabric, like tulle, over the ventilation holes and set a vinegar trap nearby to catch the adult flies.

In this guide, you’ll find out which type of fly is in your compost bin, why it showed up, how to get rid of it without pesticides and what to do so it doesn’t come back.

Why are there flies in my compost bin?

Flies show up because your compost bin gives them everything they’re looking for: fermenting food, moisture and a sheltered place to lay eggs. The most common causes are exposed fruit scraps, a mix that’s too wet, too little dry material on top and gaps in the lid or ventilation holes.

Often, the eggs come home with you on fruit peels, especially very ripe fruit. When those peels go into the compost bin and stay uncovered, the eggs find the perfect environment to hatch a new generation of flies.

In other words, flies don’t mean your composting has failed. They’re a sign that something is out of balance, almost always moisture or coverage.

What kinds of flies show up in a compost bin?

In an apartment compost bin, the most common insects are fruit flies, fungus gnats and black soldier flies. Each one shows up for a different reason, and knowing which one you have helps you choose the right fix.

Type How to recognize it What attracts it Best fix
Fruit fly (Drosophila) Very small, with a yellowish or light brown body and reddish eyes. Flies around fruit. Ripe fruit and fermenting sweet scraps Cover the scraps, freeze peels beforehand and use a vinegar trap
Fungus gnat Tiny, dark and long-legged, like a little mosquito. Doesn’t fly much and stays near the surface. A very wet mix and damp soil Reduce moisture, add dry material and use yellow sticky traps
Black soldier fly Bigger, black and wasp-like, but it doesn’t sting. The larvae are large and grayish. Large amounts of wet scraps Seal gaps well and add more dry material. The larvae help break down scraps and aren’t dangerous.

A tip to tell them apart: if the flies disappear when you remove the fruit bowl from the kitchen, they’re probably fruit flies. If they also hang around your potted plants, they’re most likely fungus gnats, which love damp soil.

How do you get rid of flies in a compost bin?

To get rid of flies, work on two fronts: remove what attracts them and catch the adults that are already flying around. Cover the scraps with plenty of dry material, fix the moisture, seal the gaps and place traps near the compost bin. That way, new eggs don’t develop and the population shrinks little by little.

Here’s the step-by-step:

  1. Cover everything with dry material. Spread a thick layer of sawdust, dry leaves, shredded cardboard or plain paper over all the contents. No food scraps should be visible.
  2. Bury fresh scraps. The next time you feed your compost bin, dig a small hole in the mix, place the scraps inside and cover them with compost and dry material.
  3. Fix the moisture. If the mix is soggy, add more dry material and stir well. If your compost bin has a leachate collector, drain the liquid.
  4. Seal the gaps. Attach a piece of tulle, voile or fine mesh over the ventilation holes and around the rim of the lid. Air still flows, but insects can’t get in or out.
  5. Set a trap nearby. Use the vinegar trap (explained below) next to the compost bin, not inside it.
  6. Be patient. Even if you do everything right, some flies will still hatch from eggs that were already there. Repeat the dry cover every time you feed the bin until they’re gone.

How do you make a homemade fruit fly trap?

The simplest homemade trap uses apple cider vinegar and dish soap. Pour a little vinegar into a small container, add a drop of dish soap and cover it with plastic wrap poked full of tiny holes. The flies go in, drawn by the smell, and can’t get out. The soap makes them sink into the liquid.

A few tips to make the trap work better:

  • Keep the trap next to the compost bin, not inside it.
  • Replace the liquid whenever it gets dirty or loses its smell.
  • A small piece of very ripe fruit inside the container makes the trap even more attractive to fruit flies.
  • For fungus gnats, yellow sticky traps, sold at garden centers, usually work better, because these insects are attracted to the color.

The trap helps, but it won’t solve the problem on its own. If the compost bin still has exposed, wet scraps, new flies will hatch every day.

Can I use insecticide in my compost bin?

It’s not recommended. Insecticide also kills the microorganisms and worms that make composting happen. Plus, the poison can stay in the compost and end up in your pots and herb garden. A dry cover, mesh over the gaps and traps solve the problem without putting your compost at risk.

The same goes for very strong homemade remedies, like alcohol mixtures or cleaning products poured straight into the compost bin. Whatever kills the flies also harms the life that turns scraps into compost.

How do you keep flies from coming back?

To keep flies from coming back, make it a habit to always cover new scraps with dry material, keep moisture balanced and leave out foods that attract insects. Freezing fruit peels before they go into the compost bin also helps, because it kills eggs that come from outside.

The habits that make the biggest difference:

  • A dry cover every time you feed the bin. Keep a container of sawdust or shredded cardboard next to the compost bin, always within reach.
  • Freeze fruit peels. Store scraps in a container in the freezer and take them to the compost bin already cold. Find more ideas in our article on how to store food scraps until composting.
  • Chop your scraps. Smaller pieces break down faster and spend less time attracting insects.
  • Leave out what attracts pests. Meat, dairy, seasoned food and grease stay out of an apartment compost bin. When in doubt, check the list of what can and can’t go in your compost bin.
  • Balance greens and browns. Wet kitchen scraps should always go in with dry material.
  • Watch your fruit bowl and trash can. Overripe fruit in the kitchen also attracts fruit flies, which then find the compost bin.

Are flies in a worm bin harmful?

Flies don’t attack worms, but they usually mean the bin is too wet, which also bothers the worms. Fixing the moisture and adding more dry cover solves both problems at once. Don’t use insecticide or harsh products, because they can kill the worms.

If you compost with worms, check out the specific care tips in our article on red wiggler worms in small spaces.

When do flies point to a bigger problem?

Flies point to a bigger problem when they show up together with a sour or rotten smell, a soggy mix or large numbers of larvae. These signs show that the compost bin is too wet and lacks air. In that case, besides covering the scraps, you need to stir well, add plenty of dry material and drain the leachate.

If things have gotten to that point, it’s worth reviewing your whole routine. Our article on the 7 common apartment composting mistakes helps you find what’s out of balance. And if your question is about the liquid draining from your compost bin, our guide to compost leachate explains what to do with it.

Summary: how to get rid of flies in your compost bin

  1. Identify the type of fly so you can choose the best fix.
  2. Cover all scraps with a thick layer of dry material.
  3. Fix the moisture and drain the leachate.
  4. Seal the gaps with tulle or fine mesh.
  5. Use traps next to the compost bin.
  6. Avoid insecticides, which kill the life in your compost.
  7. Keep up good habits so the flies don’t come back.

Flies can be alarming, but they’re no reason to give up. With a few adjustments, your compost bin gets back in balance and keeps turning your scraps into compost. If you’re just getting started, our complete guide to apartment composting shows you the way from step one.

FAQ: flies in the compost bin

Is it normal to have flies in a compost bin?

It’s common, especially at the beginning or on hot days, but it shouldn’t become routine. A few flies now and then aren’t a problem. A cloud of them every time you open the lid means there are exposed scraps or too much moisture. Add more dry cover and seal the gaps.

Do compost flies spread disease?

Fruit flies and fungus gnats are considered more of a nuisance than a health risk. Even so, it’s best not to let them spread through your home: keep the compost bin covered and away from food, and wash fruit well before eating it.

Are white larvae in my compost bin from flies?

They can be. Small, pale larvae are usually from flies. Larger, grayish and flat larvae are usually from black soldier flies, which help break down scraps and are harmless. If they bother you, add more dry cover and close the lid tightly so the adults can’t lay more eggs.

Does vinegar inside the compost bin keep flies away?

No. Vinegar attracts flies, which is why it works in traps placed next to the compost bin. Poured inside, it can attract even more insects and make the mix acidic, which slows down decomposition.

How long does it take for the flies to go away?

It depends on how many there already are and how many eggs are in the mix. Adults start to decline as soon as the scraps are covered and the traps are working. But new flies may keep hatching for a while. Keep adding a dry cover every time you feed the bin until they’re gone.

Does freezing scraps help with flies?

Yes, it does. Freezing kills eggs that came in on fruit peels and also makes scraps easier to break down. Just keep peels in a container in the freezer and take them to the compost bin when it’s time to feed it.