Crosstalk between gut and brain has long been appreciated in health and disease, and the gut microbiota is a key player in communication between these two distant organs. Yet, the mechanisms through which the microbiota influences development and function of the gut–brain axis remain largely unknown. Barriers present in the gut and brain are specialized cellular interfaces that maintain strict homeostasis of different compartments across this axis. These barriers include the gut epithelial barrier, the blood–brain barrier and the blood–cerebrospinal fluid barrier. Barriers are ideally positioned to receive and communicate gut microbial signals constituting a gateway for gut–microbiota–brain communication. In this Review, we focus on how modulation of these barriers by the gut microbiota can constitute an important channel of communication across the gut–brain axis. Moreover, barrier malfunction upon alterations in gut microbial composition could form the basis of various conditions, including often comorbid neurological and gastrointestinal disorders. Thus, we should focus on unravelling the molecular and cellular basis of this communication and move from simplistic framing as 'leaky gut'. A mechanistic understanding of gut microbiota modulation of barriers, especially during critical windows of development, could be key to understanding the aetiology of gastrointestinal and neurological disorders. The gut microbiota is an important modulator of the gut–brain axis. This Review provides an overview of barrier function across this axis and examines the role of the gut microbiota in communication across and between these specialized gastrointestinal and brain barriers in health and disease.