BACKGROUND: Socio-demographic factors and area of residence might influence the development of esophageal and gastric cancer. Large-scale population-based research can determine the role of such factors. METHODS: This population-based cohort study included all Swedish residents aged 30-84 years in 1990-2007. Educational level, marital status, place of birth, and place of residence were evaluated with regard to mortality from esophageal or gastric cancer. Cox regression yielded hazard ratios (HR) with 95% confidence intervals (CI), adjusted for potential confounding. RESULTS: Among 84 920 565 person-years, 5125 and 12 230 deaths occurred from esophageal cancer and gastric cancer, respectively. Higher educational level decreased the HR of esophageal cancer (HR = 0.61, 95%CI 0.42-0.90 in... women, HR = 0.71, 95%CI 0.60-0.84 in men) and gastric cancer (HR = 0.80, 95%CI 0.63-1.03 in women, HR = 0.73, 95%CI 0.64-0.83 in men). Being unmarried increased HR of esophageal cancer (HR = 1.64, 95%CI 1.35-1.99 in women, HR = 1.64, 95%CI 1.50-1.80 in men), but not of gastric cancer. Being born in low density populated areas increased HR of gastric cancer (HR = 1.23, 95%CI 1.10-1.38 in women, HR = 1.37, 95%CI 1.25-1.50 in men), while no strong association was found with esophageal cancer. Living in densely populated areas increased HR of esophageal cancer (HR = 1.31, 95%CI 1.14-1.50 in women, HR = 1.40, 95%CI 1.29-1.51 in men), but not of gastric cancer. CONCLUSION: These socio-demographic inequalities in cancer mortality warrant efforts to investigate possible preventable mechanisms and to promote and support healthier lifestyles among deprived groups.