The metazoan gut harbours complex communities of commensal and symbiotic bacterial microorganisms. The quantity and quality of these microorganisms fluctuate dynamically in response to physiological changes. The mechanisms that hosts have developed to respond to and manage such dynamic changes and maintain homeostasis remain largely unknown. Here, we identify a dual oxidase (Duox)-regulating pathway that contributes to maintaining homeostasis in the gut of both Aedes aegypti and Drosophila melanogaster. We show that a gut-membrane-associated protein, named Mesh, plays an important role in controlling the proliferation of gut bacteria by regulating Duox expression through an Arrestin-mediated MAPK JNK/ERK phosphorylation cascade. Expression of both Mesh and Duox is correlated with the gut bacterial microbiome, which, in mosquitoes, increases dramatically soon after a blood meal. Ablation of Mesh abolishes Duox induction, leading to an increase of the gut microbiome load. Our study reveals that the Mesh-mediated signalling pathway is a central homeostatic mechanism of the insect gut.