Socioeconomic factors and the patterns of use of health services associated with influenza and pneumococcal vaccination were studied in people aged ⩾65 years admitted to three general hospitals in Spain between 2005 and 2007. The following data were collected: age, sex, risk of pneumonia, educational level, social class, type of household, physician visits, length of time with the same general practitioner, and influenza and pneumococcal vaccination (23vPPV). Associations between variables were assessed using multivariate logistic regression analysis. In total, 1702 patients were included; 59·9% had received 23vPPV and 65·6% influenza vaccine. Older age (OR 1·04, P<0·001), living with a partner (OR 1·72, P=0·003) and influenza vaccination during the last year (OR 6·64, P<0·001) were associated with 23vPPV. Male sex (OR 1·44, P=0·005), older age (OR 1·02, P=0·009), moderate risk of pneumonia (OR 1·58, P=0·001), living with a partner (OR 1·52, P=0·015) and frequent physician visits during the last year (1–6 annuals visits (OR 2·65, P<0·001); >6 visits (OR 3·83, P<0·001)) were associated with influenza vaccination. Coordination between public health and primary-care services may be necessary to improve vaccine uptake.