You lift the lid to turn the heap and something's wrong. A hole has been dug at the base, the material inside is disturbed and hollowed out, and there's a smell that's sharper than the usual earthy rot, something closer to ammonia. Maybe there are droppings scattered across the top layer, or a patch of shredded cardboard and dry leaves pulled into a rough nest shape. If you've seen any of this, you're not imagining it: rats find compost heaps genuinely attractive, and once one has moved in, it will keep coming back until the conditions that drew it there change.
Keeping rats out of a compost heap comes down to two things working together: physically excluding them, and not feeding them.
The signs, and what they mean
Rats are wary of anything new in their environment, so you're more likely to hear or find evidence of one than actually see it, often at dusk or after dark, as a scratching or rustling from inside the heap before you ever spot a hole. Look for:
- A hole at the base of the heap or bin, often where it meets the ground, this is where a rat has burrowed in from below.
- Droppings, dark, rice-grain-sized, often clustered near an entry point.
- Gnaw marks on wooden bin panels, plastic lids, or bin corners.
- A nest of shredded paper, cardboard, or dry leaves, tucked into a hollowed-out cavity within the material.
- Greasy rub marks along the inside edge of a bin or fence line, a rat runs the same route repeatedly, and body oil from its coat gradually darkens a smear along whatever it brushes past.
- A strong ammonia smell, distinct from the sweeter, earthy smell of compost breaking down normally, this comes from concentrated urine at a nesting site.
Any one of these on its own is worth investigating; two or more together mean you're dealing with an active presence, not a one-off visitor. Don't assume every hole or dropping is a rat, either: house mice leave noticeably smaller versions of the same signs, smaller droppings, narrower gnaw marks, a smaller entry gap, and are a lesser exclusion challenge in one specific way, since a gap too small for a rat can still let a mouse through, so mesh sized to stop rats doesn't automatically stop mice too.
Handle any part of the heap that shows these signs with gloves on, and wash your hands afterwards. Rat urine can carry leptospirosis (Weil's disease), and while the risk from ordinary garden contact is low, it's not worth ignoring once you know a heap has had rats in it.
Why compost heaps attract rats in the first place
The rat in a Scottish garden is the same brown rat (Rattus norvegicus) found across the rest of the UK, and it wants the same two things from a compost heap: shelter and food. An undisturbed pile of organic material, especially one that's rarely turned, makes a warm, dry, hidden nesting site, particularly through the colder months when a rat is looking for exactly that kind of insulated, undisturbed spot. Depending on what's going into it, the same heap can also be an easy meal. A heap that's turned regularly is harder to nest in undisturbed, on top of whatever it does for the composting process itself; getting the exclusion measures below in place before autumn, rather than mid-winter once a rat has already settled in, is worth doing early.
Bird feeders and spilled seed nearby are worth checking too, they're a common co-attractant that can draw rats into a garden in the first place, after which the compost heap is simply the next thing they find.
Physical exclusion: the single most effective measure
The most important thing you can do is stop rats getting in from underneath. An open-bottomed compost bin sitting on bare earth is easy to burrow beneath, and once a rat is inside, the lid barely matters. Line the base with galvanised wire mesh before you site the bin, look for mesh sold specifically as rodent- or rat-proof rather than general garden wire netting, since ordinary chicken wire's holes are often wide enough for a young rat to squeeze through. This blocks rats out while still letting worms and other beneficial soil organisms move up into the compost, which is exactly the balance you want: Edinburgh's home composting guide recommends covering the base of the bin with fine chicken wire specifically "to prevent vermin from entering the bin from underneath while still allowing beneficial creatures such as worms to get in."

Beyond the base, three more things matter:
- A well-fitting, secure lid. A rat that can lift or squeeze under a loose lid will use it. Edinburgh's guide also suggests something as simple as putting a heavy rock on the lid, or covering the top of the heap with a piece of old carpet, to make it "less accessible."
- No gaps at the joins. Panel bins in particular can develop gaps at the corners as they age or warp, check these periodically.
- A hard, level surface, or mesh-lined earth. Standing the bin on paving or a similarly firm base removes the burrowing route entirely; on soil, lay the mesh down first and site the bin on top of it, which still gives worms and drainage the access described in hot composting vs cold piles.
A raised bin, a tumbler, for instance, that sits up off the ground on a frame, removes the burrowing route by design. Garden Organic notes that a compost tumbler is a good choice "if you have back problems, or you need to have the bin off the ground due to rats."

What not to compost, and why it matters for rats specifically
Most composting advice tells you to avoid meat, dairy, and cooked food because of smell and pathogens. That's true, but for rat prevention the more useful way to think about it is simpler: these are foods a rat can actually eat and wants to eat. Raw vegetable peelings and garden waste are not, a rat has little interest in a pile of potato peel and grass clippings once it's begun to break down.
| Waste type | Attractive to rats? | Where it should go instead |
|---|---|---|
| Raw vegetable and fruit peelings | No | Compost heap, fine as usual |
| Garden waste (grass, leaves, prunings) | No | Compost heap, fine as usual |
| Bread and other starchy or grain waste | Yes | Food waste caddy, or a bokashi system |
| Cooked food (any) | Yes | Food waste caddy, or a bokashi system |
| Meat and fish | Yes | Food waste caddy, or a bokashi system |
| Dairy | Yes | Food waste caddy, or a bokashi system |
Covering fresh scraps rather than leaving them exposed on top also helps: burying kitchen waste under a layer of soil or dry material such as leaves and cardboard, the same principle behind a compost trench, gives it far less scent for a rat to home in on than a heap left with fresh peelings sitting openly on the surface.
The Soil Association advises avoiding grains such as bread and couscous, along with meat and cooked food, specifically because they attract vermin. Edinburgh's council guide is direct about the same point: "Do not try to home compost meat, dairy or cooked foods." Its companion page on making good compost puts the logic plainly: "If you do not put cooked foods, starchy foods, meat or dairy scraps on the heap, there should not be anything there to attract either pets or vermin."
If you do want to compost cooked food, meat, or dairy, the answer isn't to put it in an open heap and hope, it's to pre-treat it. A bokashi system ferments food waste in a sealed container using an inoculated bran, and the result is, in Garden Organic's words, "inedible for rats and other creatures" once it's ready to dig into soil or add to a heap. A properly hot-running compost system can also process cooked food and dairy safely, because sustained high temperatures break the material down before it becomes an attractive meal, see hot composting vs cold piles for how to get a heap running hot in the first place.
Open heap vs enclosed bin
An open heap, just a pile of material, or one contained by loose pallets or netting, is straightforwardly easier for a rat to get into and nest in than a fully enclosed bin with a lid. A lidded bin with a mesh-lined base does most of the exclusion work by design; an open heap relies entirely on there being nothing attractive in it, a harder standard to keep to consistently, especially if a household member occasionally slips in something they shouldn't.
Real deterrents vs folklore
It's worth being blunt about what's actually proven, because a lot of what circulates as rat-deterrent advice isn't. Two remedies that come up constantly in forums and folk advice do not have credible evidence behind them:
- Peppermint oil. No institutional composting or pest-control authority documents peppermint oil as an effective rat deterrent. It's a widely repeated folk remedy, not a documented one.
- Ultrasonic pest-repeller devices. These are marketed heavily, but their effectiveness against rodents isn't supported by credible evidence. Rodents habituate to the sound within days of first exposure and carry on as before.
Save the effort those would take and put it into the mesh base and the food list instead, that's where the evidence actually is.
A note on the Scotland angle
Nothing in the available guidance suggests Scotland's brown rat population or behaviour differs meaningfully from the rest of the UK for composting purposes, the biology and the practical advice here are UK-wide. City of Edinburgh Council publishes its own official composting guidance covering this exact ground, mesh-lined bases, secure lids, keeping meat, dairy and cooked food out, the same substance as the horticultural charities above, from a Scottish local authority rather than an English one.
If your compost is on a shared allotment plot or a tenement back green, a rat problem is rarely just yours: mention it to your allotment association or neighbours early, since one poorly excluded bin can draw rats toward everyone else's plot too, not just the one it started in.
If you already have rats in your heap
Finding an active rat presence in your compost is unpleasant but manageable if you act promptly.
- Remove attractants immediately. Clear out any cooked food, meat, dairy, or starchy waste that's in there, and stop adding it going forward.
- Retrofit exclusion. If your bin doesn't already have a mesh-lined base, this is the moment to add one, along with checking the lid fits securely and there are no gaps at the joins.
- Consider professional pest control for an established infestation. If you're seeing repeated activity, a nest, or multiple animals rather than a single opportunistic visit, that's usually beyond what exclusion and diet changes alone will resolve quickly, and a pest control professional is the appropriate next step.
Setting traps or poison around the heap yourself is a separate undertaking with its own safety considerations, and not something to improvise, rodenticides sold to the public are restricted under UK stewardship rules, and using the wrong product or leaving it accessible to pets, birds, or other wildlife causes real harm beyond the rat it was aimed at. Once rats are established, get advice suited to dealing with an infestation properly, on top of the exclusion and diet changes above, not instead of them. Pest-control services and charges vary by local authority, check what your own council offers rather than assuming it's free or automatically covered.
Common questions
Will putting my compost bin on a paving slab instead of soil stop rats?
It removes the burrowing route from underneath, which is one of the two main ways rats get into a heap, but it won't help if the heap still contains food that attracts them. Exclusion and diet need to be addressed together.
Does a compost tumbler solve the rat problem on its own?
It goes a long way, because being raised off the ground removes the burrowing route, and a tumbler is usually fully enclosed with a secure lid too. It's still worth keeping meat, dairy, cooked food and starchy waste out of it, since a determined rat can exploit any gap at a join or lid seal.
Do ultrasonic pest repellers actually keep rats away from compost?
No, there's no credible evidence they work against rodents. Rats habituate to the sound within days, and no credible institutional source recommends them as an effective deterrent.
Is it true that peppermint oil deters rats from compost heaps?
This isn't supported by evidence from the composting and gardening organisations that cover rat deterrence. It's a widely repeated folk remedy rather than a documented one.
Is rat urine on my compost dangerous?
It carries a small risk of leptospirosis (Weil's disease). Wear gloves when handling material from a heap that's shown signs of rats, and wash your hands afterwards, ordinary sensible hygiene rather than a reason to avoid composting altogether.
Sources
5 sources, recorded with what each was used for
- RHS: Composting: General siting and base guidance (bare earth for drainage and soil-organism access, or a hard surface with added soil, and covering against rain); not used for any rat-specific claim
- Garden Organic: Different composting methods: Raised tumbler bins helping specifically against rats, bokashi pre-treatment making food waste inedible to rats, and hot composting bins processing cooked food/dairy safely
- Soil Association: How to make your own compost: Advice to avoid grains, meat, and cooked food specifically because they attract vermin
- City of Edinburgh Council: Home composting guide (what can/can't go in the bin): The direct instruction not to home-compost meat, dairy, or cooked foods, and to use a food waste caddy, bokashi system, or food waste digester instead
- City of Edinburgh Council: Home composting guide (making great compost): Vermin-prevention advice: keeping cooked/starchy/meat/dairy waste out of the heap, weighing down or covering the lid, and lining the base with fine chicken wire to block vermin while letting worms through

