Ants, flies, rats, mice and wasps in the compost bin
Rats, mice, fruit flies, ants and wasps in a compost pile each point to a different problem. What attracts each one, and what to do.

Pests in the compost are annoying, but they’re also information. Each one is drawn to a different condition, so the pest you’re seeing tells you a fair amount about what’s going on inside the pile.
Quick fix
- Rats: stop adding food waste that isn’t buried, and check the base isn’t giving them shelter.
- Fruit flies: bury fresh scraps under existing material instead of leaving them exposed on top.
- Mice: same fixes as rats — fine mesh under the bin, no cooked food, and disturb the pile often.
- Ants: often a sign the pile has dried out — rewet it.
- Wasps nesting in it: leave the bin alone until winter, or call a pest control service.
Rats
Rats want two things from a compost pile: food and shelter. A carelessly run pile offers both. The biggest single draw is exposed food waste, especially anything that shouldn’t be in the pile in the first place — meat, dairy, cooked food (see the guide on what not to add). But even appropriate scraps like vegetable peelings attract rats when they sit on the surface rather than being mixed into the pile.
The fix starts with what goes in and how. Bury fresh scraps under a layer of existing material or browns, and cut out meat, dairy, and cooked food entirely. Then look at the base, because burrowing up from below is often how rats get established: wire mesh under an open pile, or a bin with a closed or mesh bottom, shuts off that route. If your bin has a lid, check that it closes properly. Rats are persistent, and they will find a gap. When you dig into a pile rats have been using, wear gloves and wash your hands afterwards: rat pee can spread leptospirosis.
Mice
Mice come for the same things as rats, and they don’t need food scraps to do it. In the UK, Adur & Worthing Councils note that “even if you don’t put food on a compost heap mice and rats may find the warmth within the heap irresistible and ideal for nesting.”
The rat fixes above all apply, with a finer mesh. Scotland’s City of Edinburgh Council suggests covering the base with “fine mesh chicken wire” to keep vermin out from underneath while still letting worms in, and the US EPA says a bin should have no holes or gaps “larger than ¼ inch” (about 6 mm). England’s Derbyshire County Council adds a free one: put the bin “in a place where it will be disturbed on a regular basis (as rats and mice are very shy and hate humans)”. Turning the pile often does the same job. Wear gloves when you handle a pile mice have been using.
Fruit flies
Small flies hovering around the pile, especially near the surface, are usually drawn by exposed fresh fruit and vegetable scraps, and most people call them fruit flies. (Other small creatures in the bin, from gnats to pill bugs, are covered in bugs in the compost bin.) They’re a nuisance more than a genuine problem — they don’t damage the compost or attract larger pests on their own — but a swarm of them is unpleasant anywhere near where you sit or hang laundry.
The fix is burial. A few inches of existing compost, or a scattering of browns over each new addition, is usually enough to stop the flies reaching the scraps to lay eggs. If you’re adding scraps often, keep a small covered container in the kitchen and empty it into the pile every couple of days, burying each load as it goes in.
Ants
Ants turning up in numbers are often a sign that the pile has gone too dry. Ants prefer dry, undisturbed ground, and a moist, actively decomposing pile is too damp and too busy for them to nest in. Confirm it with the squeeze test from the too-dry guide — grab a handful from the middle and squeeze; if it crumbles apart without holding together, that’s your answer.
Rewet the pile in layers as you turn it, not just poured on top, and get decomposition active again. The ants tend to move on once the pile stays moist and the conditions that suited them are gone. Here the pest is doing you a favor: without the ants, you might not have noticed the pile had dried out and stalled.
Wasps
Wasps hovering over the bin in late summer are usually after fruit. Edinburgh’s advice: “Try burying fruit scraps in the middle of the heap.” Wasps can also nest in a dry, undisturbed pile, which is another reason to keep it moist and turned.
If there’s a nest in the bin, don’t try to dig it out or treat it yourself. Nests don’t last: Northern Ireland’s Mid and East Antrim Borough Council says “the wasps die in the autumn and the nest is never reused”. The UK’s British Pest Control Association says nests “in quiet areas can often be safely left alone”, so if you can live without the bin until winter, leave it, then carry on composting. If the bin is somewhere you can’t avoid, or anyone in the house is allergic to stings, call a pest control service.
Slugs and snails
These are part of the clean-up crew, not a pest of the pile. The UK’s Royal Horticultural Society (RHS) lists “worms, woodlice, slugs and other invertebrates” among the creatures that feed on decaying material. Nothing needs doing.
The general pattern
The pattern holds across all of them: pests show up when a pile offers something a well-run pile doesn’t — food on the surface, a way in at the base, dry undisturbed ground. Bury scraps, secure the base, keep the moisture and activity where they should be, and the large majority of pest problems solve themselves without anything beyond the pile itself. If a serious rat problem persists despite all of that, look at the location. A pile tight against a fence, or beside a shed with existing rat activity, has a problem that no amount of compost management will fix on its own.