Your own compost bin allows you to have fresh, free fertilizer for your garden and reduces the amount of garbage you create. Unfortunately, the compost bin—indoors or out—can attract many different types of flies. The most common is the fruit fly, which lays its eggs in your fruit and vegetable scraps and can quickly infest your bin. Common household flies also are attracted to some types of compost bins. With a bit of effort, you can reduce or eliminate flies in your compost bin.
Take the lid off of your compost bin, serving two purposes. First, it allows the flies to escape. Some don't necessarily want to stay in the bin, but they can't get out. It also can help dry your compost a bit, as compost that is too moist attracts flies.
Lure flies away from your bin. Place a banana peel in a jar and cover it with plastic wrap, cutting a small slit in the wrap. Fruit flies will be attracted to the banana peel and will enter the jar, but will be unable to get out.
Keep your fruit and vegetable scraps in an air-tight container. Most people keep scraps in a container in the kitchen until they are able to bring them outside to the compost pile. If it is left open, flies can enter and lay eggs in the material, which will be transferred to your compost bin.
Cover kitchen scraps thoroughly. Flies will be attracted to your compost bin if they can small the kitchen scraps. When you add them to your pile, cover it with other organic matter, such as leaves or lawn clippings.
Add more high carbon materials. The Massachusetts Department of Environmental Protection states that the presence of fruit flies means that there is not enough high-carbon materials in your compost. Add brown leaves, shredded paper or cardboard to eliminate the problem.