We have undertaken a systematic investigation of the effect of nonmagnetic impurities on the residual (T0 K) electron-spin-resonance linewidth of erbium in dilute [200 parts per million atomic (ppm)] Er:Ag alloys. The nonmagnetic impurities used were In, Sn, Sb, Y, and Lu in the concentration range of 500-4600 ppm. The linewidth broadening caused by these impurities was found to be 0.2±0.11, 0.49±0.1, 0.51±0.11, 1.4±0.18, and 1.37±0.32 G/1000 ppm atomic frequency (GHz) for In, Sn, Sb, Y, and Lu, respectively. The most reasonable source of the Er line broadening is the mixing of the crystal-field levels of the Er by the Kohn-Vosko oscillations in the charge density. The broadening of the Er resonance line due to In, Sn, and Sb doping is consistent with the expected form of the oscillations. Also, Y and Lu are equivalent in the broadening of the Er line, as expected. However, the scaling of the Y and Lu broadening compared to that due to the In, Sn, and Sb is not consistent. The reasons for this are not understood.