Compost is made from piling organic matter, such as leaves and vegetable scraps, into a certain area or container. After a while, the pile naturally breaks down into soil-like matter that is used as a soil amendment and fertilizer. The decomposition process is helped by natural bacteria, insects and earthworms. However, if too much moisture is available or the wrong type of organic material is added to the pile, a large number of flies may suddenly appear over and around the compost pile. Too many flies can also be caused by adding fresh manure or vegetable scraps to the pile without adding enough dry matter.
Turn the compost pile once to redistribute the organic matter in the pile with a garden fork. Simply move the organic matter at the bottom of the pile to the top of the pile. This buries any fly larvae that may be ready to hatch or that have hatched.
Add dry organic matter to the compost pile such as hay, dry leaves or wood chips. Turn the pile once again to incorporate the dry matter into the pile. This dries out the pile, removing excess moisture, and adds carbon matter. Do not add water to the pile after adding the dry matter until the fly problem goes away.
Sprinkle a layer of soil about 1/2 inch thick over the top of the compost pile. This buries all fly larva and makes the pile inaccessible to the flies. Once the flies are no longer visible, turn the pile and incorporate the dirt into the pile. The dirt contains microorganisms that help the compost pile decay rapidly. The dirt also helps soak up any excess moisture in the pile that may be attracting flies.