Higher Th17 cells (/CD4+) [odds ratio (OR) = 1.573, P = 0.001], history of diabetes (yes vs. no) (OR = 3.574, P = 0.008), Helicobacter pylori infection (positive vs. negative) (OR = 2.964, P = 0.005), higher TNM stage (OR = 3.685, P < 0.001), and postoperative complications (yes vs. no) (OR = 4.858, P < 0.001) were all independently correlated with increased anxiety risk in elderly gastric cancer patients. The gene discussed is CD4; the disease is gastric cancer.