Why Are Flies So Attracted to Feces?

Learn how flies use advanced chemical detection to find the essential substrate needed for laying eggs, and the resulting health risks.

Flies are drawn to feces because it broadcasts a cocktail of volatile chemicals that signal two things flies need most: food and a place to lay eggs. To a fly, a pile of dung is a neon “vacancy” sign advertising warmth, moisture, microbial activity, and nutrients for the next generation. The chemistry behind this attraction is surprisingly specific, and different fly species respond to different chemical signatures depending on their own biology and life stage.

The Chemical Signals That Pull Flies In

Feces release dozens of volatile organic compounds as bacteria break down undigested proteins, fats, and carbohydrates. Flies do not respond to all of them equally. Research on stable flies identified a blend of nine polar compounds, including urea, lactic acid, and a branched-chain acid called 3-methylbutyric acid, that attracted flies just as effectively as the real thing when mixed synthetically. The researchers also noted that not every compound in the blend was necessary, meaning flies are responding to a pattern of odors rather than a single magic ingredient.

A different set of compounds dominates cattle dung. The chemical p-cresol, a phenol derivative with a sharp, barnyard smell, is the most abundant volatile in fresh cow pats. It attracted female horn flies and stimulated them to lay eggs, along with terpenes like α-pinene that most people associate with pine trees. Phenol and cresols also attract stable flies in lab and field tests, with low concentrations working better than high ones and certain two-compound blends outperforming individual chemicals. In other words, the “stink” of feces is not a single smell to a fly. It is a layered signal, and the relative proportions matter as much as the individual compounds.

How Flies Detect Fecal Odors

Flies are built to read chemical landscapes. The primary smell organs sit on the antennae, specifically on a segment called the funiculus at the base of the antenna’s third major piece. Studies on face flies confirmed that these basal segments house the olfactory receptors responsible for detecting bovine fecal odors. These receptors are extremely sensitive. A fly cruising downwind can pick up fecal volatiles at concentrations far below what a human nose would notice, locking onto the odor plume and following it upwind to the source.

Smell is the dominant sense for finding feces, but it is not the only one. Flies also use visual cues like dark patches on lighter ground, and they can sense heat and moisture gradients that fresh dung produces. These layers of sensory input help explain why flies zero in so quickly on a new deposit and why fake visual decoys alone rarely fool them for long.

Bacteria Are Doing Much of the Work

A fresh pile of feces is a thriving microbial ecosystem, and many of the volatiles that attract flies are actually produced by bacteria, not by the feces itself. Research on stable fly feces isolated seven bacterial species, two of which produced nearly identical odor profiles containing compounds like dimethyl disulfide, dimethyl trisulfide, and several ketones. Both bacteria also emitted carbon dioxide and ammonia, which act as general attractants for many fly species. This means bacteria are not just passive inhabitants of dung; they actively shape its chemical signature in ways that draw more flies in.

The relationship goes further. Blow flies carry bacterial symbionts that contribute to what researchers call the “fly factor,” a phenomenon where decomposing material already visited by flies becomes more attractive to additional flies. The bacteria deposited by the first wave of visitors change the odor profile, essentially amplifying the signal. This creates a positive feedback loop: a few flies land, their bacteria alter the chemistry, and the altered chemistry recruits more flies.

Not All Feces Are Created Equal

One of the more interesting findings in this area is that flies are choosy about whose feces they visit. Fruit flies (Drosophila) show a strong aversion to carnivore feces but are indifferent to or even attracted by herbivore dung. The key difference comes down to a single compound: phenol, which is present at high concentrations in the feces of meat-eating animals. A specific class of sensory neurons detects phenol and triggers an egg-laying avoidance response. The bacterial communities in carnivore and herbivore feces also differ sharply, with carnivore feces harboring a higher proportion of disease-causing bacterial families. So the fly’s aversion appears to be an evolved defense: carnivore feces are more likely to contain pathogens dangerous to developing larvae.

Among herbivore manures, flies show clear preferences too. When house flies were given free choice among several types of livestock manure, the highest numbers were attracted to cow manure. Yet reproductive performance, including larval development speed and adult fecundity, was often better on poultry manure. A separate study confirmed that maggots reared on poultry manure developed faster and produced more fecund adults than those raised on cow, horse, sheep, or goat dung. The disconnect between what attracts adult flies and what best supports their offspring hints that attraction cues and actual nutritional quality do not always line up perfectly.

Diet composition matters even within a single animal species. When researchers compared feces from cows fed different rations, a fly species called Musca sorbens refused to lay eggs unless the dung contained odors from digested concentrated feed supplements. The attraction was linked to nutritional needs of the larvae, not just protein content alone. Meanwhile, not every fly species even benefits from fecal feeding: the Mexican fruit fly showed no increase in egg production when given access to bird droppings, despite reports that related fruit fly species use bird feces as a nitrogen source.

What the Fly Needs Changes What It Seeks

A fly’s attraction to feces is not static across its lifespan. Young green bottle flies that have not had a protein meal are equally drawn to feces and carrion, because at that life stage they need protein for egg development and either source will do. But once a female has fed on protein and her eggs are mature, she shifts her preference entirely toward carrion and ignores feces. The same chemical cues are present in the environment, but the fly’s brain reweights them based on internal state. Feces serve as a feeding resource; carrion serves as a nursery. What changes is the fly’s priorities, not the available odors.

This helps explain a pattern anyone who has spent time outdoors has noticed: the flies buzzing around a dog pile in the park are often different individuals, at different life stages, from the ones that would cluster around a dead animal. Both groups are “flies attracted to gross stuff,” but they are doing fundamentally different things.

Feces As a Nursery

For many fly species, the primary reason to visit feces is not to eat but to reproduce. Dung is warm, moist, rich in bacteria, and soft enough for tiny larvae to burrow through. House fly larvae develop well in the manure of animals fed a mixed diet, while black soldier fly larvae accept a wider range of decaying organic matter. In practical terms, a single cow pat can produce hundreds of adult flies if nothing else colonizes it first.

Larvae do not just passively consume the dung. They digest bacteria using a combination of digestive enzymes, lysozyme, and antimicrobial compounds that keep them from being overwhelmed by the pathogens surrounding them. Flies have essentially evolved a biochemical toolkit that lets them thrive in an environment most other animals could not survive. The combination of antimicrobial gut defenses and a short developmental period, often just a few days from egg to pupa, allows flies to exploit feces before competition and desiccation destroy the resource.

Why This Makes Flies Dangerous to Human Health

The same behaviors that make feces attractive to flies make flies dangerous to people. House flies breed in manure and then land on food, carrying whatever pathogens stuck to their bodies or lingered in their digestive tract. A systematic review of housefly-associated pathogens documented that house flies feed and reproduce in feces and other decaying material, then shuttle back and forth to human dwellings, transmitting microbes mechanically along the way.

The list of pathogens is long. Synanthropic fly species, the ones that live alongside humans, transmit bacteria including Salmonella, E. coli, Listeria, Klebsiella, and Campylobacter. Their contact with manure and animal waste also enables the transfer of antibiotic-resistant bacteria across food production systems. Beyond just carrying pathogens on their feet and mouthparts, flies store what they eat in a structure called the crop, then regurgitate it onto surfaces when they next land to feed. This crop-regurgitation cycle keeps pathogens viable and ready for transmission well after the fly has left the original fecal source.

Using Fecal Chemistry Against Flies

Understanding which chemicals attract flies to feces has practical applications for pest control. Rather than blanketing an area with insecticide, researchers have been developing odor-based traps that mimic fecal volatiles. Binary blends of phenol mixed with either m-cresol or p-cresol caught more stable flies in field trials than single compounds alone. Similar work on horn flies showed that p-cresol and α-pinene could be used to lure egg-laying females away from cattle.

These attract-and-kill or attract-and-trap strategies have an edge over broadcast spraying because they target specific pest species while leaving beneficial insects largely alone. The challenge is tuning the blend precisely: too much of a compound and flies are repelled, too little and the trap does not compete with real dung nearby. Researchers continue working on optimizing these blends, and the approach has already moved from lab olfactometers into field deployments on cattle farms.

Dung Beetles and the Fight Over the Same Resource

Flies are not the only animals racing to colonize feces. Dung beetles compete directly with fly larvae by burying dung, shredding it, and using it to provision their own offspring. In summer dung, when conditions favor faster decomposition, the competition is intense: beetle activity reduces fly survival significantly, probably by killing eggs and young larvae as beetles tear apart the pat. One dung beetle species, Onthophagus ferox, caused greater bush fly mortality than a related species because it buried more dung and did so faster, preemptively removing the resource before fly larvae could develop.

This relationship has been leveraged deliberately. Australia famously imported dung beetles from Africa and Europe starting in the 1960s to combat its bush fly problem, since the continent’s native beetles had evolved to handle marsupial droppings and could not cope with the vast quantities of cattle dung from introduced livestock. Research in the Amazon similarly found that dung beetle richness and biomass correlated with lower dung-fly abundance, though beetles were not the only factor. Land-use intensity also played a role, with more disturbed landscapes supporting fewer beetles and more flies.

The Other Side of the Story: Nutrient Recycling

For all the disease risk flies pose, their attraction to feces plays a genuine ecological role. When fly larvae chew through manure, they accelerate decomposition and release nitrogen and phosphorus back into the soil. Biodegradation of animal manures by fly larvae produces organic fertilizer with fast nutrient release, potentially reducing the amount of synthetic fertilizer farmers need to apply. Both black soldier fly and house fly larvae reduce manure volume and alter its nutrient and heavy-metal composition, though the degree of reduction depends on the type of manure and the scale of the operation.

Black soldier fly farming has become a growing industry precisely because of this ability. Facilities feed food waste and manure to soldier fly larvae, which convert it into protein-rich biomass for animal feed while shrinking the waste pile. The larvae’s appetite for organic waste, including feces, is being turned into a commercial asset rather than a nuisance.

Flies, Feces, and Forensic Investigations

The predictable way different fly species colonize decomposing organic matter, including the fecal material released during death, gives forensic scientists a tool for estimating how long a body has been in a particular location. Fly species arrive in a known sequence, and the developmental stage of the larvae found at a scene can be used to work backward to a time of colonization. Even buried remains are not exempt. The scuttle fly Megaselia scalaris, small enough to burrow through loose soil, has been recovered from buried carcasses and has also been documented on human corpses, making it relevant to cases involving concealed remains.

The same chemical sensitivity that pulls flies toward feces and decay is what makes them such reliable early colonizers of remains. Their olfactory system can detect the volatile signatures of decomposition from considerable distances, often before any visible change is apparent to a human observer. In forensic contexts, the flies’ seemingly repulsive habits become an asset: their biology provides an independent biological clock that does not depend on witness testimony or surveillance footage.