Metformin is commonly used, but approximately 20% of patients experience gastrointestinal intolerance, leading to medication discontinuation for unclear reasons and a lack of effective management strategies.In this study, the 18 fecal and blood samples were analyzed using 16S rRNA and mRNA transcriptome, respectively. These samples included 3 fecal and 4 blood from metformin-tolerant T2D patients before and after metformin treatment (T and Ta), 3 fecal and 5 blood from metformin-intolerant T2D patients before and after treatment (TS and TSa), and 6 fecal samples from healthy controls.The results showed that certain anti-inflammatory gut bacteria and gene, such as Barnesiella (p = 0.046), Parabacteroides goldsteinii (p = 0.016), and the gene JUND (p = 0.0002), exhibited higher levels in metformin-intolerant patients, and which decreased after metformin treatment (p < 0.05). This potentially invalidates patients' anti-inflammatory effect and intestinal mucus barrier protection, which may lead to alterations in intestinal permeability, decreased gut barrier function, and gastrointestinal symptoms, including diarrhea, bloating, and nausea. After metformin treatment, primary bile acids (PBAs) production species: Weissella confusa, Weissella paramesenteroides, Lactobacillus brevis, and Lactobacillus plantarum increased (p < 0.05). The species converting PBAs to secondary bile acids (SBAs): Parabacteroides distasonis decreased (p < 0.05). This might result in accumulation of PBAs, which also may lead to anti-inflammatory gene JUND and SQSTM1 downregulated.In conclusion, this study suggests that metformin intolerance may be attributed to a decrease in anti-inflammatory-related flora and genes, and also alterations in PBAs accumulation-related flora. These findings open up possibilities for future research targeting gut flora and host genes to prevent metformin intolerance.