Stroke is a life-threatening condition that impairs the arteries and causes neurological impairment. The incidence of stroke is increasing year by year with the arrival of the aging population. Thus, there is an urgent need for early stroke diagnosis. Short-chain fatty acids (SCFAs) can modulate the central nervous system and directly and indirectly impact behavioral and cognitive functions. This study aimed to investigate the connection between SCFA metabolism and stroke development via bioinformatic analysis. Initially, the Gene Set Enrichment Analysis (GSEA) and immune cell infiltration analysis were performed based on RNA data from stroke patients to comprehend the mechanisms governing stroke pathogenesis. The functional analysis, including Gene Ontology (GO), Kyoto Encyclopedia of Genes and Genomes (KEGG), and Protein-Protein Interaction (PPI), was performed based on the Differentially Expressed Gene (DEG) selected by the limma package. 1220 SCFA metabolism-related genes screened from Genecards databases were intersected with 242 genes in main modules determined by Weighted Gene Co-Expression Network Analysis (WGCNA), and the final 10 SCFA key genes were obtained. GO analysis revealed that these genes were involved in immune response processes. Through lasso regression analyses, we established a stroke early diagnosis model and selected 6 genes with diagnostic value. The genes were validated by the area under curve (AUC) values and had a relatively good diagnostic performance. Finally, 4 potential therapeutic drugs targeting these genes were predicted using the Drug Signatures Database (DSigDB) via Enrichr. In conclusion, this paper analyzes the involvement of SCFAs in the complex gut-brain axis mechanism, which contributes to developing new targets for treating central nervous system diseases and provides new ideas for early ischemic stroke diagnosis.