Cognitive function in humans depends on the complex and interplay between multiple body systems, including the hypothalamic-pituitary-adrenal (HPA) axis. The gut microbiota, which vastly outnumbers human cells and has a genetic potential that exceeds that of the human genome, plays a crucial role in this interplay. The microbiota-gut-brain (MGB) axis is a bidirectional signalling pathway that operates through neural, endocrine, immune, and metabolic pathways. One of the major neuroendocrine systems responding to stress is the HPA axis which produces glucocorticoids such as cortisol in humans and corticosterone in rodents. Appropriate concentrations of cortisol are essential for normal neurodevelopment and function, as well as cognitive processes such as learning and memory, and studies have shown that microbes modulate the HPA axis throughout life. Stress can significantly impact the MGB axisviathe HPA axis and other pathways. Animal research has advanced our understanding of these mechanisms and pathways, leading to a paradigm shift in conceptual thinking about the influence of the microbiota on human health and disease. Preclinical and human trials are currently underway to determine how these animal models translate to humans. In this review article, we summarize the current knowledge of the relationship between the gut microbiota, HPA axis, and cognition, and provide an overview of the main findings and conclusions in this broad field.