AimsThe prognosis and quality of life of heart failure patients is determined to a significant extent by co‐morbidities. New data suggest that heart failure may be associated with an increased incidence of cancer. The present retrospective study investigates this association in a large collective of outpatients with heart failure.Methods and resultsThis retrospective cohort study assessed the incidence of cancer in patients with an initial diagnosis of heart failure and a matched non‐heart failure cohort in 1274 general practices in Germany between January 2000 and December 2018. The study is based on the Disease Analyser database (IQVIA), which contains drug prescriptions, diagnoses, and basic medical and demographic data. Hazard regression models were used to study the association between heart failure and the incidences of different cancers. A total of 100 124 patients with heart failure and 100 124 patients without heart failure were included in the analysis. Patients were matched individually by sex, age, diabetes, obesity, and yearly consultation frequency. Within the 10 year observation period, 25.7% of patients with heart failure and 16.2% of patients without heart failure had been diagnosed with cancer (log‐rank P < 0.001). These proportions were 28.6% vs. 18.8% in female and 23.2% vs. 13.8% in male patients. Heart failure was significantly associated with the incidence of cancer [hazard ratio (HR), 95% confidence interval: 1.76, 1.71–1.81; P < 0.001 in total; HR: 1.85, 1.77–1.92, P < 0.001 in women; HR: 1.69, 1.63–1.76, P < 0.001 in men]. A significant association was found between heart failure and all cancer sites assessed. The strongest association was observed for cancer of lip, oral cavity, and pharynx (HR: 2.10, 95% confidence interval: 1.66–2.17; P < 0.001), followed by respiratory organs (HR: 1.91, 1.74–2.10; P < 0.001) and genital organs of female patients (HR: 1.86, 1.56–2.17; P < 0.001). The association for skin tumours was 1.83 (1.72–1.94; P < 0.001), for cancer of lymphoid and haematopoietic tissue 1.77 (1.63–1.91; P < 0.001), for cancer of the digestive tract 1.75 (1.64–1. 87; P < 0.001), for breast cancer 1.67 (1.52–1.84; P < 0.001), for cancer of the genitourinary tract 1.64 (1.48–1.81; P < 0.001), and for male genital organ cancer 1.52 (1.40–1.66; P < 0.001).ConclusionsOur study indicates that heart failure patients experience a significantly higher incidence of cancer during the course of the disease.