Stop maggots in compost by removing their food source and adjusting moisture and temperature
Maggots in compost are fly larvae, usually from black soldier flies or common house flies. They appear when flies lay eggs on exposed food scraps, especially meat, fish, dairy, or oil. The larvae themselves do not harm finished compost, but they signal that your bin is too wet, too warm, or has too much exposed food. Stopping them means burying food waste, lowering moisture, and raising temperature through better mixing.
The fastest fix is to bury all food scraps under at least 4 inches of brown material — dry leaves, shredded paper, or cardboard. Maggots need air and light to thrive near the surface. Once buried, they either move deeper into the pile or die. If the problem is severe, you can also remove the top layer of compost, bury the maggots deeper, and cover everything with a thick brown layer.
Key Takeaways
- Bury food scraps under 4 inches of dry brown material to cut off light and air that maggots need to survive near the surface.
- Reduce moisture by adding more dry leaves or cardboard and turning the pile more often to speed decomposition and raise internal temperature.
- Avoid adding meat, fish, dairy, oils, and cooked food — these attract flies and create the conditions maggots prefer.
- If maggots are already present, remove the top layer of compost, bury the maggots deeper, and cover with brown material to stop new flies from laying eggs.
Why flies lay eggs in your compost bin
Flies lay eggs on exposed food waste because it is warm, moist, and straightforward for larvae to eat. Black soldier flies and common house flies both target compost bins. The eggs hatch in 8 to 20 hours, and larvae grow for 3 to 5 days before moving deeper into the pile or crawling away to pupate. If you see maggots, flies have already been there.
Certain foods attract flies more than others. Meat, fish, bones, dairy, oils, and cooked food are the strongest draws. Fruit and vegetable scraps attract flies too, but less aggressively. The wetter your pile, the more attractive it becomes — moisture keeps food soft and straightforward for larvae to consume. A dry, well-mixed pile decomposes faster and stays less appealing to flies.
Bury food scraps to cut off light and air
The simplest prevention is to bury every food scrap under brown material as soon as you add it. Use dry leaves, shredded newspaper, cardboard, or wood chips. Push the food down into the pile, then cover it with at least 4 inches of brown material. Maggots need oxygen and light to live near the surface — burying them removes both.
If you already have maggots, remove the top 6 to 8 inches of compost and set it aside. Dig down to where you see the larvae, push them deeper into the pile, and cover everything with a fresh 6-inch layer of dry brown material. This buries the maggots and blocks new flies from laying eggs on the surface. Repeat this step if flies return within a few days.
Lower moisture to slow larvae growth
Maggots thrive in wet compost. A pile that smells like ammonia or feels soggy is ideal for them. To dry it out, stop adding wet food scraps for a week or two, and add dry leaves, shredded paper, or cardboard instead. Turn the pile every 2 to 3 days — this mixes wet and dry material, speeds evaporation, and raises the internal temperature through friction.
Aim for a moisture level like a wrung-out sponge: damp but not dripping. If your bin has a lid, leave it off for a day or two to let moisture escape. If it has drainage holes, make sure they are not blocked. A drier pile not only discourages maggots but also decomposes faster and smells better.
Raise temperature by turning the pile more often
Maggots slow down in hot compost. A pile that reaches 130°F or higher will kill most larvae. You cannot control temperature directly, but you can raise it by turning the pile every 2 to 3 days. Turning mixes fresh material with decomposing material, which speeds bacterial activity and generates heat.
A smaller bin (3 to 4 feet on each side) heats up faster than a large one. If you have room, consider a second bin so you can move finished compost out and start fresh. The more often you turn, the hotter the pile gets, and the faster maggots die. Even if you do not have maggots now, regular turning prevents them from appearing.
Stop adding foods that attract flies
Meat, fish, bones, dairy, oils, butter, and cooked food are the strongest attractants for flies. If you want to compost these items, you need a hot bin that reaches 130°F or higher, turned regularly. Most home bins do not get hot enough. The safest approach is to skip them entirely and stick to fruit and vegetable scraps, coffee grounds, eggshells, and plant material.
If you have already added meat or fish, bury it as deep as possible and cover it thickly. The smell will fade as decomposition continues, and flies will be less likely to find it. Going forward, reserve those items for a municipal composting program if your area has one, or throw them in the trash.
Use a bin with a tight-fitting lid and drainage
A bin with a lid that closes tightly keeps flies out. Flies cannot lay eggs if they cannot reach the food. Drainage holes at the bottom let excess moisture escape without creating a soggy environment. If your bin does not have a lid, cover it with a piece of plywood or cardboard weighted down with a brick.
Worm bins and enclosed tumblers are especially fly-resistant because they seal completely. If you are starting fresh and maggots are a recurring problem, an enclosed bin is worth the investment. Even a straightforward plastic storage container with a tight lid and a few drainage holes drilled in the bottom works well.
Frequently Asked Questions
Do maggots ruin compost?
No. Maggots are decomposers and actually speed up the breakdown of food waste. The finished compost they help create is safe to use in gardens. The problem is not the maggots themselves but the flies they attract and the smell they can cause. If you do not mind the flies and odor, you can leave them alone.
Can I use salt or lime to kill maggots?
Salt kills maggots but also harms the beneficial bacteria and microbes that break down compost. Lime raises pH and can slow decomposition. Burying maggots and adjusting moisture and temperature are more effective and do not damage your compost. If you want a chemical option, diatomaceous earth (food-grade) can be sprinkled on maggots, but burying them is simpler.
How long does it take to get rid of maggots?
If you bury them and cover with brown material, most maggots will move deeper or die within 2 to 3 days. If you also turn the pile and lower moisture, they disappear faster. Preventing new flies from laying eggs is the key — once you stop the cycle, the problem ends within a week.
Can I still use compost that had maggots in it?
Yes. Once the maggots are gone and the compost is finished (dark, crumbly, and earthy-smelling), it is safe to use in gardens and potted plants. Maggots do not leave behind anything harmful. Finished compost is finished compost, regardless of what helped break it down.
What if I keep getting maggots no matter what I do?
Switch to a fully enclosed bin with a tight lid, or move to a worm bin. If your current bin is in a warm, shaded spot where flies congregate, moving it to a sunnier or more exposed location can help. You can also stop composting meat, fish, and dairy entirely and stick only to plant scraps. A combination of these changes will stop the cycle.