Shiga toxin-producing Escherichia coli (STEC) infections have been associated with severe illness. Ruminants are seen as the main reservoir and the major transmission route is considered to be foodborne. In The Netherlands, a case-control study was conducted, using data collected during 2008–2012. Patients were interviewed and controls completed a self-administered questionnaire. Patients travelling abroad were excluded from the analyses. STEC O157 and non-O157 were examined separately and differentiated into two age groups (<10 years, ⩾10 years). We included 130 O157 cases, 78 non-O157 cases and 1563 controls. In both age groups of O157 patients, raw spreadable sausage was the main risk factor for infection. For STEC non-O157 cases aged <10 years, contact with farm animals was the main risk factor and in non-O157 cases aged ⩾10 years, consumption of beef was the main risk factor. During 2008–2012, risk factors for STEC infections in the Dutch population differed between age groups and serogroup categories, and were related to eating meat and contact with farm animals. Advising the public about the risks of consuming raw or undercooked meat (products) and hygiene habits in case of contact with farm animals, could help in the prevention of STEC infections.