Objective The aim of this research was to explore the effects on echinococcosis of harmine, an active ingredient of Peganum harmala. Methods The gene targets were screened out by use of an online database. STRING was exploited to build a protein interaction network model, DAVID to carry out gene ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) enrichment analyses, and AutoDockTools for molecular docking. All mice were randomly divided into 3 groups: a model group, a normal group, and a harmine group. Blood indicators were detected and histological analysis was carried out. NCTC-1469 was treated with either harmine or control. Gene expression was evaluated by Western blot. Results Network pharmacological analysis concluded that 6 gene targets (HLA-B, HLA-DQB1, IL-6, tumor necrosis factor [TNF], HLA-A, and F3) might act as the major targets in the treatment of echinococcosis with harmine. GO function and KEGG pathway enrichment analyses showed that harmine might treat echinococcosis mainly by regulating the immune response. Molecular docking confirmed that harmine docked well to the targets and that the interactions were reliable. Harmine could regulate the content of inflammatory factors to modulate the immune response of mice, but caused liver damage. Pathological histology analysis confirmed that harmine had great suppressive efficacy against echinococcosis infection. However, the use of harmine would have a certain negative effect on the spleen of mice. The contents of HLA-B, HLA-DQB1, TNF, HLA-A, and F3 were observably enhanced, while Interleukin-6 was reduced in mouse liver tissue and cells after harmine treatment. As forecast by network pharmacology, harmine exerted antiechinococcosis effects by multiple targets and pathways. Finally, harmine treatment might regulate the Th17/Treg balance in mice with echinococcosis infection. Conclusions Harmine displayed great suppressive efficacy against echinococcosis infection by regulating the immune response. These findings suggest that harmine could be a potential therapeutic agent for echinococcosis management by targeting specific gene targets.