Background: A dysregulation of cytokine networks has been suggested to be involved in the pathogenesis of unexplained pregnancy loss. Gut microbiota affects host immune response and induces an imbalance in cytokine levels. However, how gut microbial dysbiosis affects the disturbance of cellular immune function in spontaneous abortion (SA) patients remains inconclusive.Results: Serum proinflammatory cytokine levels were significantly increased in SA patients. Microbial diversity in patients with SA was reduced compared with that in the controls, as were the relative abundances of Prevotella_1, Prevotellaceae_UCG_003, and Selenomonas_1 were significantly reduced in the cases. Fecal metabolomics profiles were altered in SA patients, and the correlation analyses indicated that some microbe-associated metabolites, which were significantly enriched in bile secretion and histidine metabolism pathways, were positively associated with changes in levels of IL-17A, IL-17F, TNF-α, and IFN-γ in the SA group. Moreover, the microbial-associated metabolites, imidazolepropionic acid and 1, 4-Methylimidazoleacetic acid, are associated with recurrent pregnancy loss.Conclusions: Our study highlights the network among gut microbiome, fecal metabolites and Th1/Th17-mediated immune response in miscarriage patients and identifies potential novel biomarkers and an intervention target for recurrent miscarriage.