BackgroundThe prognosis of patients with colorectal cancer is related to early detection. However, commonly used screening markers lack sensitivity and specificity. In this study, we identified diagnostic methylation sites for colorectal cancer.MethodsAfter screening the colorectal cancer methylation dataset, diagnostic sites were identified via survival analysis, difference analysis, and ridge regression dimensionality reduction. The correlation between the selected methylation sites and the estimation of immune cell infiltration was analyzed. The accuracy of the diagnosis was verified using different datasets and the 10-fold crossover method.ResultsAccording to Gene Ontology, the main enrichment pathways of genes with hypermethylation sites are axon development, axonogenesis, and pattern specification processes. However, the Kyoto Encyclopedia of Genes and Genomes (KEGG) suggests the following main enrichment pathways: neuroactive ligand–receptor interaction, calcium signaling, and cAMP signaling. In The Cancer Genome Atlas (TCGA) and GSE131013 datasets, the area under the curve of cg07628404 was > 0.95. For the NaiveBayes machine model of cg02604524, cg07628404, and cg27364741, the accuracies of 10-fold cross-validation in the GSE131013 and TCGA datasets were 95% and 99.4%, respectively. The survival prognosis of the hypomethylated group (cg02604524, cg07628404, and cg27364741) was better than that of the hypermethylated group. The mutation risk did not differ between the hypermethylated and hypomethylated groups. The correlation coefficient between the three loci and CD4 central memory T cells, hematological stem cells, and other immune cells was not high (p < 0.05).ConclusionIn cases of colorectal cancer, the main enrichment pathway of genes with hypermethylated sites was axon and nerve development. In the biopsy tissues, the hypermethylation sites were diagnostic for colorectal cancer, and the NaiveBayes machine model of the three loci showed good diagnostic performance. Site (cg02604524, cg07628404, and cg27364741) hypermethylation predicts poor survival for colorectal cancer. Three methylation sites were weakly correlated with individual immune cell infiltration. Hypermethylation sites may be a useful repository for diagnosing colorectal cancer.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12885-023-10922-2.