Weaning is stressful for piglets involving nutritional, physiological, and psychological challenges, leading to an increase in the secretion of cortisol, changes in gut microbiome and metabolites, whereas the underlying relationships remain unclear. To elucidate this, 14 Meishan female piglets were divided into the weaning group and the suckling group at the age of 21 days paired by litter and body weight. After 48 h of experiment, weaned piglets had lower body weight, but higher salivary cortisol level than that of their suckling litter mates (
P
< 0.05). The composition of the colonic bacterial community and metabolites were different between the two groups, and the first predominant genus of the suckling and weaned piglets colonic microbiome were
Bacteroides
and
Prevotellaceae-NK3B31 group
respectively. The suckling piglets had higher proportions of phylum
Bacteroidetes
and
Lentisphaerae
, and genus
Bacteroides
and
Lactobacillus
in the colonic microbial community, but lower abundance of genus
Prevotellaceae-NK3B31 group
than that of the weaned piglets (
P
< 0.05). Accordingly, there were 15 colonic metabolites differed between the two groups, in which 2 metabolites (phenylacetic acid and phenol) negatively related to the abundant of
Lactobacillus
genus (
P
< 0.05), while 9 metabolites (acetic acid, arabitol, benzoic acid, caprylic acid, cholesterol, dihydrocholesterol, galactinol, glucose phenol, phenylacetic acid, and oxamic acid, glycerol, propionic acid) positively associated with the proportion of
Prevotellaceae-NK3B31 group
genus (
P
< 0.05). Furthermore, the salivary cortisol level negatively associated with the abundance of phylum
Lentisphaerae
, but positively associated with the phylum
Bacteroidetes
and the genus
Prevotellaceae-NK3B31 group
(
P
< 0.05) respectively. These results provide us with new insights into the cause of the gut microbiome and stress, and the contributions of gut microbiome in metabolic and physiological regulation in response to weaning stress.