The association between herpes zoster and subsequent cancer risk is still unclear. Consequently, doubts remain regarding the need for investigation of herpes patients for co-existing or subsequent malignancy. This is a retrospective cohort study comparing cancer risk in patients after herpes zoster and age-/sex-matched non-herpes zoster patients, in a primary care-based continuous morbidity database. We tested for interaction by gender, age, diabetes, HRT use or antiviral therapy. Analyses were repeated for patients with and without herpes simplex. The hazard ratio (HR) comparing cancer risk in herpes zoster vs. control patients was significant in all women, women aged > 65 years and subgroups of breast and colorectal cancer (HRs 1·60, 1·82, 2·14, 2·19, respectively). For men, a significant association was found for haematological cancers (HR 2·92). No associations were found with herpes simplex. No interaction was identified with antiviral therapy, diabetes or HRT treatment. We concluded that there was a moderate significant association between herpes zoster and subsequent cancer risk in women aged > 65 years, without any influence of antiviral therapy. No association was found with herpes simplex. There is insufficient reason for extensively testing older patients with herpes zoster or herpes simplex for the presence of occult cancer.