During sunset and sunrise, the sun is at a larger distance from earth. The shorter wavelength get scattered while travelling through the atmosphere and the larger wavelength is visible to the observer. That is why the sun appears red during sunset and sunrise