ObjectivesTo examine the risk of a subsequent pulmonary or extra-pulmonary cancer diagnosis following a first-time hospital-based diagnosis of pneumonia. DesignPopulation-based cohort study using Danish medical registries. SettingAll hospitals in Denmark. SubjectsA total of 342609 patients with a first-time hospital-based (inpatient, emergency room or outpatient clinic) diagnosis of pneumonia between 1995 and 2011. Main outcome measuresWe quantified the excess risk of various cancers amongst pneumonia patients compared to the expected risk in the general population, using relative [standardised incidence ratios (SIRs)] and absolute risk calculations. Follow-up started 1month after a hospital-based diagnosis of pneumonia and ended on 31 December 2011. ResultsA total of 28496 cancers were observed, compared with 21625 expected, amongst 342609 pneumonia patients followed for a median of 4.2years. The absolute risk of a cancer diagnosis 1 to <6months following a pneumonia diagnosis was 1.4%, with a corresponding SIR of 2.48 [95% confidence interval (CI) 2.41-2.55]. This was mainly due to an increased risk of lung cancer (eightfold) and haematological cancers (fourfold). The SIR for any cancer remained increased at 1.35 (95% CI 1.30-1.40) during 6-12months of follow-up, and 1.20 (95% CI 1.18-1.22) during 1-5years of follow-up. Beyond 5years, an increased risk was maintained for lung, oesophageal, liver and bladder cancers, squamous cell carcinoma of the skin, lymphoma and multiple myeloma. ConclusionsA hospital-based pneumonia diagnosis was associated with an increased risk of a cancer diagnosis, especially in the ensuing months, but the absolute risk was small.