Background Angiotensin-converting enzyme inhibitors (ACEIs) and angiotensin receptor blockers (ARBs) are used in treating cardiovascular diseases. Previous studies indicated that ACEIs/ARBs may benefit cancer patients by inhibiting tumor angiogenesis and proliferation. The effect of ACEIs/ARBs on cancer survival in esophageal and gastric cancer is still unclear. This study is to investigate the association between ACEIs/ARBs usage and esophageal and gastric cancer prognosis. Methods This retrospective cohort study identified esophageal and gastric cancer patients during 2008-2016 from the Taiwan Cancer Registry, and obtained medication usage and follow-up information from the National Health Insurance Research Database and Death Registry. Analysis groups were defined as ACEIs/ARBs user or non-user based on the usage of ACEIs/ARBs within the 6 months after cancer diagnosis. The stabilized inverse probability of treatment weighting using propensity scores was applied to balance covariates between study groups. We also used Kaplan-Meier estimates and Cox regression to compare survival outcome and estimate hazard ratios (HRs). Results We identified 14,463 and 21,483 newly-diagnosed esophageal and gastric cancer patients during 2008-2016. ACEIs/ARBs users were associated with lower risk of cancer-specific mortality, although only significantly in gastric cancer (gastric: adjusted HR = 0.87, 95% CI = 0.78-0.97; esophageal: adjusted HR =0.88, 95% CI = 0.76-1.02). A better survival outcome was observed among patients who received higher cumulative defined daily dose of ACEIs/ARBs. Conclusions We found that using ACEIs/ARBs after cancer diagnosis were associated with lower risk of mortality. Our results add to the knowledge of the benefit of ACEIs/ARBs against mortality in individuals with esophageal/gastric cancer patients with hypertension.