Compost Blog: Eradicate Fruit Flies in Compost 1. Bury the fruit and veg You can bury the food waste that flies are attracted to in the middle of your compost bin, with other material above and to the side. This approach means getting a bit hands-on with your compost and making sure the food waste is not accessible. It's not easy, as you need a lot of brown non-food waste to cover.