BackgroundEsophageal cancer (ESCA) is a highly invasive malignant tumor with poor prognosis. This study aimed to discover a generalized and high‐sensitivity immune prognostic signature that could stratify ESCA patients and predict their overall survival, and to discover potential therapeutic drugs by the connectivity map.MethodsThe key gene modules significantly related to clinical traits (survival time and state) of ESCA patients were selected by weighted gene coexpression network analysis (WCGNA), then the univariate and least absolute shrinkage and selection operator (LASSO) Cox regression analyses were used to construct a 15‐immune‐related gene prognostic signature.ResultsThe immune‐related risk model was related to clinical and pathologic factors and remained an effective independent prognostic factor. Enrichment analyses revealed that the differentially expressed genes (DEGs) of the high‐ and low‐risk groups were associated with tumor cell proliferation and immune mechanisms. Based on the gathered data, a small molecule drug named perphenazine (PPZ) was elected. The pharmacological analysis indicates that PPZ could help in adjuvant therapy of ESCA through regulation of metabolic process and cellular proliferation, enhancement of immunologic functions, and inhibition of inflammatory reactions. Furthermore, molecular docking was performed to explore and verify the PPZ‐core target interactions.ConclusionWe succeed in structuring the immune‐related prognostic model, which could be used to distinguish and predict patients' survival outcome, and screening a small molecule drug named PPZ. Prospective studies also are needed to further validate its analytical accuracy for estimating prognoses and confirm the potential use of PPZ for treating ESCA.