BACKGROUND: Community-acquired pneumonia (CAP) significantly affects elderly patients, leading to high morbidity and mortality rates. This study investigates the interplay between mental health, nutritional status, and comorbidities in determining the prognosis of elderly patients with CAP. METHODS: A retrospective cohort study was conducted with 455 patients aged 75 and older who were hospitalized for CAP. Clinical data, including demographic information, comorbidities, and laboratory results, were collected. The WHO-5 Well-Being Index (WHO-5), Mini Nutritional Assessment Short Form (MNA-SF), and Charlson Comorbidity Index (CCI) were utilized to assess mental health, nutritional status, and comorbidity burden. Statistical analyses included logistic regression, Kaplan-Meier survival analysis, and mediation analyses. RESULTS: The study found that the 28-day mortality rate was 9.67%, while the 90-day mortality rate reached 12.31%. Spearman's correlation analysis revealed significant positive correlations between the WHO-5 Well-Being Index and MNA-SF scores (r = 0.560) and albumin levels (r = 0.245), while negative correlations were observed with CCI (r = -0.202) and C-reactive protein levels (r = -0.242). Logistic regression analysis indicated that comorbidity, malnutrition, lower well-being, CAP severity, and mechanical ventilation are significant predictors of 28-day and 90-day mortality. Kaplan-Meier survival analysis demonstrated statistically significant differences in cumulative survival among various well-being groups. Multiple mediation analyses showed that mental well-being and nutritional status significantly mediated the association between CCI and 28-day and 90-day mortality. CONCLUSION: This study emphasizes the critical roles of mental health, nutritional status, and comorbidities in the prognosis of elderly patients with CAP. Integrating these factors into clinical assessments may provide insights to inform management strategies, potentially improving patient outcomes and reducing mortality rates in this vulnerable population.