Like bugs, ants, and other critters, worms are naturally drawn to compost and tend to help the process by breaking the organic matter down faster. In moderation, they can contribute to the overall aeration and health of the compost. But if your compost is overrun, you will need to remove them.
Here are some ways that you can get rid of white worms in your compost:
- Adjust the pH of your pile.
- Bait and remove.
- Break up and bury your greens.
- Add more browns.
- Check the air holes.
- Assess the composition of your feedstock.
- Aerate your compost pile.
- Cover your compost.
- Make a fruit fly trap.
In this article, I’ll go into detail about these methods to get rid of white worms in your compost and how you can keep them out, so read on!

1. Adjust the pH of Your Pile
The ideal pH of a healthy compost ranges from 7 to 8, although compost piles can have pH values that vary between 4.9 – and 8.3.
The white worms in your compost may be grubs, the larvae of soldier flies. Alternatively, if the worms are thin and look smaller, white versions of the red wigglers, they’re probably pot worms.
Both of these types of organisms thrive in the pH range of 6 – 7, so they do well in a healthy compost pile. Worms and maggots don’t harm your compost in any way. They speed the composting process by helping the microbes process the green matter.
But if you’re grossed out by them or find that the worms and maggots have overrun your compost pile, you could encourage them to leave by changing the pH of your compost pile.
Raising the pH
One way to change the pH balance of your compost is to add powdered lime, phosphorus, or crushed eggshells to the pile.
Powdered lime or calcium hydroxide is commonly used in gardening applications to raise the pH of acidic soils. Raising the pH makes the soils a most hospitable environment for plants that prefer a more alkaline base. You can use the lime in your compost pile to the same effect, as using powdered lime will raise the pH of the compost and make it inhospitable for the white worms.
Phosphorus and crushed eggshells will have the same effect as powdered lime. While powdered lime will work faster, crushed eggshells are more likely to keep the alkalinity of your compost within healthy levels to prevent the compost from affecting your garden adversely when it’s ready.
Lowering the pH
You can also shift the pH of your compost in the opposite direction by adding vinegar or citrus peels like those of orange, lemon, or lime fruits. These additions will make the compost pile more acidic, and you will see an immediate reduction in the population of white worms.
However, it is essential to be careful when adding citrus peels. These tend to decompose very slowly and may kill off the microbes in your compost pile if used excessively, leading to a too wet compost pile.
If you’re using vermicomposting, you should not use amendments that make the compost more acidic, as the acidity will kill your red wigglers and the white worms and maggots.
Distribute the Amendment(s)
You don’t need much of the amendments, so add a little. After adding your pH amender of choice, turn your compost to mix it, whether you’re composting with or without a bin, to ensure that the amender is distributed evenly.
As the pH of your compost pile changes, you’ll notice a reduction in the number of white worms in your compost pile.
2. Bait and Remove
Potworms and maggots appear in compost piles because they’re attracted to organic matter. They eat through the greens in your composting feedstock and process them and, in that sense, help you by composting your greens faster.

However, if you find far too many worms and grubs and want to get rid of them immediately, you can simply bait them with food and remove them from the pile.
Using this method is a good idea if you’re overwhelmed by the white worms in your compost and want to get rid of the mass while waiting for the other, more long-term methods to work.
The most recommended way of baiting white worms is to use a slice of stale bread soaked in milk. Place this soaked slice on top of your compost pile, and wait for the worms to clamber on. You can then remove the slice and the worms from the pile and dispose of them.
Another potential bait is to use banana peels, as these appeal to fruit fly larvae. Once the worms or larvae have clambered onto the peel, you can remove them from the compost with the peel.
Using the bait and remove method helps you thin out the crowd of worms in your pile as you wait for the compost to become otherwise inhospitable to bugs.
3. Break up and Bury Your Greens
As I’ve mentioned earlier, the greens in your composting feedstock are the element that attracts worms and grubs to your compost pile. This may mean that your greens are more exposed than they should be, making it easy for these worms or fruit flies to find your compost pile and reproduce in it.
A great way to get rid of white worms in your bin is to break up and bury the greens in your composting feedstock.
Breaking up the greens is crucial because they add nitrogen and moisture to the compost pile, which also means that they tend to stick to each other as they decompose.
A clump of greens will decompose slowly, bringing down the heat in your composting pile, which results in partially decomposed compost. This will lead to uneven decomposition or even anaerobic decomposition, which are both signs of unhealthy composting.
Burying the greens is part of the correct ‘lasagna layering’ method. This method requires you to layer the browns and greens in your composting pile like a lasagna, starting and ending with the browns.
This layering method ensures that the green layers are always sandwiched between carbon-rich browns. The browns will absorb moisture and odors, preventing the decomposing greens from clumping together, breaking down unevenly, or attracting any pests like white worms and grubs to the compost pile.

4. Add More Browns
Browns, greens, and moisture are the three essential elements of composting feedstock. Balancing all three is crucial to a healthy compost as they all add something that the other cannot compensate for.
Greens add nitrogen and moisture, and in dry climates or situations, you might even need to water your compost to keep the moisture levels optimum. Too dry compost is usually too acidic for the microbes to thrive, which will eventually lead to anaerobic decomposition.
Composting feedstock is incomplete without browns, as the browns add carbon, structure, and aeration to the pile. Browns like twigs and sticks also break down slowly, much slower than the moisture-rich greens. They absorb and contain the moisture and odors from the decomposing greens and prevent your compost pile from getting too wet.
If you have insufficient browns in your feedstock, the odors from the greens will escape and attract pests and bugs to your compost pile, including white worms and larvae, which will come seeking food.
The maggots and worms thrive in extremely moist conditions, so the lack of browns will encourage them to multiply rapidly.
When gathering your feedstock, it is important to remember that you need far more browns than greens to ensure that all wet organic material is fully covered. A good ratio for browns to greens is 3:1. Maintaining the right balance of browns to greens in your composting feedstock is key to getting rid of white worms in your compost.
Browns that you can add to your compost include dried leaves, coffee chaff, sawdust, and unprocessed paper or cardboard as long as they’re torn up into small pieces.
When layering your compost pile, you should ensure that you sandwich your greens between browns and that the layer of browns is three times thicker than the layer of greens. A thick layer of browns will keep your greens covered completely, preventing odors or liquids from escaping your pile.

5. Check the Air Holes
If you’re composting with a bin, you will naturally need to ensure that your composting unit has good ventilation. If you find white worms like pot worms or maggots in your pile, it might be an indication of insufficient aeration.
Check the air holes in your composting bin. The holes may have gotten blocked by a mass of composting feedstock, blocking airflow and increasing the overall moisture levels in your pile.
Clearing out any potential blocks and turning the compost will improve the aeration of your compost pile, which will, in turn, get rid of the white worms.
Another reason to check the air holes in your composting unit is to assess if they’re large enough for fruit flies or soldier flies to go through. If they are large enough, you’ve found the entryway through which the flies can access your compost piles to lay eggs in them.
The best way to address the issue of your air holes being an entryway for flies is to make them inaccessible to the flies in some way. The simplest way is to add mesh over the holes, which will maintain the airflow in the pile with holes too small for flies to get through and access your compost.

6. Assess the Composition of Your Feedstock
It is important to know what you can and cannot add to the feedstock when you’re composting. Adding materials that cannot be composted can have detrimental effects on your compost, from leaching harmful chemicals into your soil to attracting pests and scavengers like bears to your compost pile.
When it comes to the greens, the things that can be composted include kitchen scraps like fruit and vegetable peels and trims, coffee grounds and filters, yard waste like grass clippings and pruned leaves, and manure.
You should not add dairy products, meat, fat, or other trimmings from animals into the compost pile. These materials decompose slowly and need more heat to break down than produced in the average home composting pile.
The smells from decomposing dairy and meat products usually attract scavengers and pests, including pot worms and grubs, to your compost pile.
To get rid of white worms, assess the composition of your composting feedstock, and remove any dairy or meat products. If they’re buried in your pile, you should turn the pile a few times until you’ve identified the largest pieces emitting odors and remove them.

7. Aerate Your Compost Pile
Aeration is crucial for the proper breakdown of your compost pile. The aeration introduces oxygen into the pile, which is necessary for the microbes that process and break down the greens in your compost setup.
When the microbes are active and working effectively, they’re able to increase the temperature of the compost pile, which accelerates the aerobic decomposition in your compost.
When you don’t aerate your compost, the microbes are unable to thrive, and they die out. The compost pile becomes cold and wet, and anaerobic decomposition sets in, which is the primary cause of foul odors emanating from your compost pile.
The odors attract pests like white worms into your compost and other critters and scavengers.
In contrast, a healthy compost pile has a high pH value, typically too alkaline for white worms, including pot worms and maggots. Additionally, the heat produced by active microbes in a well-aerated compost is high enough that it prohibits worms and other pests from living or multiplying in your compost pile.
8. Cover Your Compost
The type of composting unit you use and where it is placed within your property will determine the kind of coverage that your compost needs.
If you’re composting in a pile outside or practicing in-ground composting, you will be covering the pile with a thick layer of browns. The final layer of browns on top should be thick enough to cover all the food in your compost pile.
If you’re composting in a bin, you may or may not choose to use a bin with a lid. Most commercial bins that are placed indoors have lids. However, if you’ve built your own, you might not have made one.
The function of lids and thick layers of browns are the same. The cover prevents odors from escaping your compost pile, which prevents scavengers and pests like white worms from finding and inhabiting your compost.
Covering the compost pile will also help increase the temperature of your pile, which results in quicker decomposition.
This increased temperature gets rid of white worms in your compost in two ways. The first is that worms and larvae cannot thrive in high temperatures. Additionally, the increased temperature will reduce the overall moisture of the compost pile, which is not conducive to the worms’ health.
Accelerated decomposition will also eliminate the worms as there will be less organic matter for the worms to feed on. Compost that is ready quicker will also get rid of worms because the pH of healthy compost will be too alkaline for the worms to live in, as they prefer more acidic environments, with pH levels between 6 – 7.
9. Make a Fruit Fly Trap
If you notice that the majority of the white worms are thick and fairly large, your compost pile is infested with maggots or larvae, which emerge from eggs laid by fruit flies or soldier flies. The fruit flies in your compost bin might be attracted to the greens because all the decomposing organic matter is food.
These flies then lay eggs in your compost, which hatch and thrive, growing into fruit flies that come back to your bin to lay eggs time and again.
The best way to get rid of white worms in your compost in such a situation is to set up a trap for fruit flies near your composting unit.
An easy, non-toxic fruit fly trap involves mixing apple cider vinegar with dishwashing liquid. The fruit flies will be attracted to the vinegar smell (which is why they’re also known as vinegar flies) and land on the mixture. The dishwashing liquid will then pull the flies into the trap.
Place a mixture of ¼ cup (60 ml) vinegar with a few drops of dishwashing liquid at the air holes or the lid of your composting unit. You could also place the trap a little distance away from the compost. This way, any smells from your pile won’t distract the flies.
Eventually, with no flies to lay any eggs, the larvae will die out. If you want to remove them quicker, you can bait and remove the worms in your pile, as discussed earlier, while the trap prevents any further larvae from thriving.
Final Thoughts
If you need to get rid of the white worms in your compost, there are plenty of methods you can consider, including:
- Adjusting the pH of your pile to make it too alkaline or acidic for the worms
- Baiting them with food and removing them
- Breaking up and burying your greens
- Adding more browns
- Covering ventilation with mesh
- Keeping dairy and meat out of your pile
- Aerating the compost pile well
- Covering your pile
- Setting a trap to keep flies from laying eggs in your compost
They are all effective, and you can choose which one works best for you.