Why Are There Flies and Maggots in My Compost?

Opening a compost bin to find clouds of flies or clusters of white maggots is an unpleasant surprise that puts many people off composting. It is worth understanding what you are actually looking at before taking action — some flies and larvae in a compost bin are completely harmless and even beneficial, while others signal a problem that is easy to fix once you know the cause.

Black Soldier Fly Larvae: Actually Beneficial

The large, dark, slightly armoured larvae you often find in compost bins during warm months are black soldier fly larvae. Despite their alarming appearance, these are among the most beneficial composting organisms you can have. They break down organic matter rapidly, produce minimal odour, and do not bite, sting, or carry disease. Their presence does not indicate a problem with your pile — it indicates a pile that is warm, moist, and full of organic material, which is exactly what you want. If you find them, leave them to do their job. They will pupate and leave on their own.

Small Fruit Flies: A Minor Nuisance

Tiny flies hovering around the bin when you open it are usually fruit flies, attracted by fermenting fruit scraps. They are harmless and pose no risk, but they can become a nuisance in large numbers, especially if the bin is close to the house or a back door. The solution is to bury fresh fruit waste in the pile immediately rather than leaving it on the surface. Covering fresh additions with a layer of dry browns — leaves or cardboard — creates a physical barrier that discourages egg-laying. A layer of damp newspaper over the top of the pile also helps.

Housefly Maggots: A Sign of a Problem

Pale, cream-coloured maggots that appear in large, dense clusters, particularly around cooked food, meat, or dairy, are housefly larvae. Unlike black soldier fly larvae, these do indicate a problem — specifically, that materials that should not be in a standard compost bin have been added. Houseflies are opportunistic and will lay eggs on any exposed food-like material. Remove the problem material if you can find it, cover the affected area with a thick layer of dry browns, and avoid adding any cooked food, meat, or dairy going forward. The maggots themselves will not harm the compost, but the underlying cause needs addressing.

How to Reduce Flies in General

Most fly problems come down to exposed fresh material on the surface. Every time you add kitchen scraps, bury them in the pile and cover with dry material. Keep a lid on the bin at all times. A fine mesh screen over any ventilation holes prevents flies from entering while still allowing airflow. Adding a layer of wood chips or dry leaves as a permanent top layer creates an effective barrier. If flies are coming from a specific type of material — citrus peel, for example, which they seem to find particularly attractive in quantity — reduce how much you add at once and always cover it immediately.

Should You Remove the Maggots?

In most cases, no. Removing maggots from a healthy pile is unnecessary work that disrupts the composting process. If they are black soldier fly larvae, leave them entirely. If they are housefly maggots and the underlying food problem has been removed, they will complete their life cycle harmlessly and the population will drop once the attractive material is gone. Only intervene if the infestation is so heavy that it is preventing you from managing the bin, in which case turning the pile and mixing in dry browns will reduce the population while improving conditions at the same time.

Manage Your Compost With Confidence

The SelfEcoFarm composting guide covers everything from creatures in the pile to smells, moisture, and materials — so nothing catches you off guard.

Get the composting guide