Background: Dietary N-nitroso compounds and endogenous nitrosation are important carcinogenic factors, but human evidence of their role is scarce for esophageal cancer and inconsistent for gastric cancer. Objective: We studied the relation between risks of esophageal and gastric cancer subtypes and dietary intake of N-nitrosodimethylamine, heme iron, nitrite, and nitrate in the Netherlands Cohort Study. Design: A total of 120,852 men and women aged 55-69 y were recruited in 1986, and diet, based on a 150-item food-frequency questionnaire, and other risk factors were assessed. The cohort was followed for 16.3 y, and 110 esophageal squamous cell carcinoma (ESCC), 151 esophageal adenocarcinoma, 166 gastric cardia adenocarcinoma, and 497 gastric noncardia adenocarcinoma (GNCA) cases were analyzed along with 4032 subcohort members in a case-cohort analysis. Results: Positive associations were observed between N-nitrosodimethylamine intake and ESCC risk (HR for 0.1-μg/d increase in intake: 1.15; 95% CI: 1.05, 1.25; P-trend = 0.01 based on tertiles of intake) and GNCA risk (1.06; 95% CI: 1.01, 1.10; P-trend = 0.09) in men. ESCC risk was associated with nitrite intake (HR for 0.1-mg/d increase: 1.19; 95% CI: 1.05, 1.36; P-trend = 0.06) and heme-iron intake (HR for 1-mg/d increase: 1.83; 95% CI: 0.98, 3.39; P-trend = 0.03). Among women, exposure levels were lower, and we found no convincing positive associations. Conclusion: These results suggest that N-nitroso compounds may influence the risk of ESCC in men, but there are no clear associations for other esophageal and gastric subtypes.