Check out my new book!

“A Publishers Weekly top ten pick!”

How to Get Rid of Fruit Flies in Your Compost Pile

May contain affiliate links. Please see my privacy policy and affiliate disclosure.

It can be frustrating to deal with fruit flies in compost piles. These easy tricks will substantially reduce their population.

galvanized bucket with quince scraps

Fruit flies in compost – ick!

I have to admit, when I first started composting, I was horrified to find bugs in my pile. I didn’t want earwigs and sow bugs in there! What I didn’t realize is that those bugs were all a part of the decomposition process. Some bugs commonly found in compost actually feed on the decaying matter, while some feed on other bugs.

Nematodes, mites, snails, slugs, earthworms, millipedes, and sow bugs are the primary consumers of the organic matter in a compost pile.

The bigger bugs in the pile – centipedes and beetles, say – are secondary or tertiary consumers, meaning that while they’re not technically helping break down the compost, by eating those primary consumers they are part of the life cycle there.

(Check out the compost food chain that’s shown on this page about invertebrates in the compost pile if you’re really interested in the science of your compost heap.)

Related: Natural Aphid Control in a Pesticide Free Garden

vegetable scraps held by hand over compost pile

How to get rid of fruit flies

Much as I understand now that bugs are just part of the process, I really don’t like the fruit flies that populate my compost pile. When their population is out of control, they fly up in a cloud of wings every time I toss something new on the pile, seemingly intent on making their way into my nose.

And it’s not just that. Fruit flies can wreak havoc in the garden. The females lay their eggs just under the skin of soft fruit. There’s nothing worse than cutting into a tomato to find little squiggly maggots. Well, I take that back. Worse is biting into a piece of fruit to find little squiggly maggots.

Figuring out how to get rid of fruit flies once they’ve taken over the pile is harder than simply preventing the problem in the first place, so I do my best to keep the problem in check. [Read about getting read of fruit flies in the kitchen here.]

Preventing fruit flies in compost

I find that the best way to prevent an overabundance of fruit flies is to make it harder for them to get to the material they like. They’re after the kitchen cast offs, not the dry leaves and grass clippings. I try to maintain a layer of undesirable materials at the top of the pile. When I add food scraps to the compost, I lift this layer and tuck the kitchen waste below it. [More about the basics of composting here.]

shredded paper and paperboard takeout container in a compost pile

Related: 7 Organic Pest Control Methods

How to get rid of fruit flies by adjusting your compost balance

If you’re finding that your pile is really infested with fruit flies, it’s likely that your pile needs more carbon. Add dry leaves, straw, or shredded newspaper to create a higher ratio of carbon to nitrogen.

Consider fruit fly traps

Fruit fly traps hung above or near the compost pile will attract the flies and prevent them from reproducing. I have one that I made out of a plastic bottle (kind of like this) with a lure inside and it attracts a fair amount of flies. I’ve also had success with banana peels and wine as an attractant.

Uncover your compost pile

When I’ve kept lidded compost bins, the fruit flies seemed to be worse. Maybe because the flies are trapped inside where they lay more eggs, multiplying quickly? I honestly don’t know, but I don’t keep a lid on my compost any more. (Remember, we don’t have much in the way of compost raiding critters here, so I can get away with this.)

This is more about prevention than how to get rid of fruit flies, of course.

Related: Natural Pest Control in The Garden

compost bin with cloth tarp folded out of the way

Hot compost

A hot compost pile will prevent the larval stage of fruit flies (maggots) from surviving in all but the outer (cooler) areas of the pile. If you’ve got a hot compost pile I’d be curious to know if fruit flies are an issue for you.

Do you have any other tricks for taming the fruit flies in compost? Please share!

Originally published June 2011; this post has been updated.

Click to save or share!

Meet the Author

Kris Bordessa

Kris Bordessa founded Attainable Sustainable as a resource for revitalizing vintage skills. Her book, Attainable Sustainable: The Lost Art of Self-Reliant Living (National Geographic) offers a collection of projects and recipes to help readers who are working their way to a more fulfilling DIY lifestyle.

22 comments… add one
  • Roxanne @ Champion of My Heart Jun 7, 2011, 1:41 pm

    I’m a little creeped out now. And, itchy. I feel itchy.

    • Kris Bordessa Jun 7, 2011, 4:35 pm

      Aw, Roxanne. We’ll convert you, little by little!

  • Alexandra Jun 7, 2011, 3:55 pm

    But wouldn’t the hot water kill the good bugs as well as the fruit fly eggs?

    • Kris Bordessa Jun 7, 2011, 4:34 pm

      Yes, the boiling water will kill all the little buggies. I wouldn’t do this unless it was a really dire fruit fly situation.

  • Living Large Jun 8, 2011, 2:42 am

    Hmm. I’m still at a quandary as to why you have to eliminate them, except that you don’t like them because they fly up your nose. 🙂 I’m inclined to let the natural order of things take over the compost pile.

    • Kris Bordessa Jun 8, 2011, 8:15 am

      Living Large, I try to keep the fruit fly population in check because the fruit flies actually sting/damage the vegetables growing in my garden.

  • Liz Jun 23, 2011, 5:49 pm

    Thanks for the tips. I also get annoyed with the fruit flies in summer and worry that I’m just breeding them so they can fly around and ruin all the fruit and veges in my garden. I will try the lid off next summer. At the moment, being winter here in Aus, I don’t have any flies, but I have been battling a family of rats that took up residence in my compost bin! I ended up trapping them (and only because I thought they would attract snakes to my garden, otherwise I would have let them stay).

  • April Nov 8, 2011, 5:59 am

    So how do you keep rats and mice out?

    • Elle Feb 26, 2018, 8:10 am

      Last summer, we had such a bad roach infestation, I had to use a commercial fogger, which I hated to douse the rooms with chemicals, but they were everywhere. Back then we just threw everything in the trash, like most people. We decided to begin composting all organic kitchen scraps in a plastic bin placed outside, in the yard, about 1 foot away from the house. Anything organic was thrown out the window, into the bin. Anything with food residue not compostible, like butter wrappers, bones or pizza boxes, was taken to the big dumpster and not kept in the house. 6 months later, we discovered a little ecosystem had formed around the compost bin. For one, we stopped getting roaches in the house – they were attracted to the fruit peels and leftovers, so they were drawn outside to the bin. We also used to have mice that would come in the house, because mice eat roaches. The roaches would eat the mouse poop and the mice would eat the roaches, it was a bad cycle, colonies of mice feeding colonies of roaches. Once I started composting outside, I guess the mice figured out the roaches were all around the bin, so they went to the bin too. Then, I began to notice owls and other predatory birds through the window, swooping down very close to the compost bin. I hadn’t seen these birds before, they too have figured out where all the mice hang out. Spring is coming and its starting to warm up, so far I’ve only spotted a few roaches outside near the bin. Our house has been amazingly roach and mouse free for the first time I can remember. I don’t even hear the mice scurrying on the roof like we used to. Lots more sightings of predatory birds in the trees outside. We’ll see how it goes with summer rolling in, but so far I’m liking what is happening. I read somewhere that owls eat 6-10 mice a night. That is why it is important not to use rat poison – if an owl dies from eating a poisioned mouse, that leaves behind hundreds of mice to keep breeding. The food chain makes a pyramid that gets smaller at the top, so 1000 roaches feeds 100 mice, and one owl eats 100 mice every two weeks. One poisioned mouse can kill the entire owl family, if it feeds it to the young. So you need to keep the owls/hawks/egrets/eagles alive. Maybe help them out by installing an owl box high up in a tree for them to nest in? Last summer I bought the plastic reusable mouse traps that snap on the mouse and kill it without poision, then I throw the bodies out in the empty lot across from my house, where the birds will come and pick it up. Anyway my system appears to have balanced itself out, with no roach poison or rat poison used. The only problem is fruit flies now, which is more of an annoyance. I’ll take fruit flies over a mouse /roach infestation any and every day.

      • Kris Bordessa Feb 27, 2018, 10:31 am

        This is so interesting!

      • Chris Aug 10, 2019, 6:08 am

        Great information! Thank you

    • Billie Grider Jun 12, 2019, 5:53 am

      Peppermint oil works to keep rodents away! My storage and garage has been spider and rodent free for years now!! But be careful around cats ! It kills them too!!

    • Amber Jun 22, 2019, 8:36 am

      Chickens… They keep the creepy crawly things from over populating the compost heap and they’re good mousers.

  • Linda Trefts Jun 3, 2016, 2:09 am

    Whenever I dump my kitchen scrap bucket into my compost bin, I add a layer of shredded junk mail. (Magazine subscription cards are great for this). The paper adds extra brown to my abundant green. Since I started doing this added step, I’ve noticed LOTS of worms in my compost and very few flies.

  • Stephanie S Sep 16, 2018, 10:25 am

    Thanks for the info! Love your site!

    • Kris Bordessa Oct 17, 2018, 9:47 am

      Thanks!

  • Shannon Nov 11, 2018, 12:30 pm

    I have a really big fruit fly problem in my compost. It’s my fault entirely, for not realising to cover the food scraps before putting them in the compost bin. I do that now, but I also do not have a lot of “browns” to draw from for in my compost (am constantly having to add paper) and even then it is always wet. I’ve seen lots of methods for getting rid of fruit flies, but my question is – will trying to increase the amount of browns in my compost help reduce flies? Or, considering how fast they multiply, am I best to start again with the composting? I would really prefer not to, but I feel like I am fighting a losing battle here.

    • Kris Bordessa Nov 11, 2018, 1:47 pm

      Well, as I say, they’re a problem due to inconvenience, not because they’re actually BAD for the pile. I’d add a deep layer of shredded paper and perhaps even cover it with a tarp.

  • Leigh Dec 15, 2018, 9:23 pm

    I didn’t see it mentioned above, so I’ll just add that when I start seeing fruit flies in the house, I pour a small bowl of apple cider vinegar. I have found that it works better with a teaspoon of sugar added. You can either add a couple drops of dish soap to the top of the liquid or cover the dish with recycled plastic wrap. The soap breaks the tension on the surface so the flies will sink. If using plastic wrap, use an ice pick or tooth pick (or fork!) to poke a few very small holes in the wrap. The holes let the flies in but they can’t get out. Thank you for the tips on getting rid of those pests outside!

  • Jeanette Mar 7, 2019, 8:14 am

    Thanks! We have an orange tree and have been putting them into the compost with not enough browns :/ . So now we have so many fruit flies! They are annoying. Aside from that we have noticed a lot of white yellow foam (probably mold from organges not too sure). We also have regular green mold from the organges. Does this mean I need to start over my compost? And, if I do where do I dispose of it? I was so excited to start composting 5 months ago now my partner is saying that it isn’t working. Help! I really want to continue composting more for the sake of the environment since I don’t actually have a garden.

    • Kris Bordessa Mar 8, 2019, 5:15 pm

      Mold and fungus is normal in a compost pile, at some level. The best thing to do if the pile is too wet (often the case with mold) is to add lots more carbon materials. Give it a chance!

  • janet myers Jun 16, 2019, 1:16 am

    We had an invasion in our kitchen of fruit flies, then we bought two compost bins for outside, and they are mostly in the bins now. But the method of putting apple cider viniger, with water, and a couple of drops of washing up liquid, and a bit of sugar, stir it all up, then cover the jar with clear plastic clingfilm, this then gets poked with a cocktail stick.. This is absolutely amazing… In one day, the bottom of the jars were covered in sunk fruit flies… it really worked… after about a month, you may need to add some more apple cider to it.. They are attracted to this mixture and you can quickly reduce the invasion this way. We made three jars, and it worked super fast. I do get a swarm of them when I open the compost bin, and we have a full cherry tree near it, so I may begin to add more shredded paper, thanks for that tip.

Leave a Comment