In an optimizing model of epidemics several externalities arise when agents shield to avoid infection. Optimizing behaviour delays herd immunity but also reduces overall infections to approximately the minimum consistent with herd immunity. For reasonable parameter values, and with no vaccine, we find that agents delay too much because of a “rat race to shield”: they shield too much in the hope that others catch the disease and reach herd immunity. This and other externalities drive large wedges between private and social outcomes. The expectation of a vaccine reverses the effects, and agents shield too little.