Anti-vaccine sentiments are growing in many countries. There are policies, like mandatory vaccination in public schools, trying to limit contacts between vaccinated and unvaccinated people. We study a dynamical epidemiological model, based on attitudes toward a vaccine that can immunize against the infection, where homophily between pro-vax and anti-vax people is the parameter of interest. In a model with exogenous vaccination choices, in case of temporary outbreaks of the disease, homophily slows down the recovery process. This happens also when we endogenize vaccination choices, even if in this case it is possible that homophily increases vaccination rates in the society.