Must a Man Cover His Head?

Is there an obligation for a man to cover his head? 

In OC 2:6, the Shulchan Aruch writes, “It is forbidden to walk in an upright posture and one must not walk four cubits with one’s head uncovered.”

This seems to imply that it is halachically forbidden for one to be bareheaded at all times, and not merely during prayer. This also seems to be his opinion in the Beit Yosef, OC 8.

On the other hand, in OC 91:3, the Shulchan Aruch writes, “Some say that it is forbidden to say God’s name with an uncovered head…And some say we should protest those who enter the synagogue with an uncovered head.”

This seems to imply that it is not absolutely forbidden for one to be bareheaded, and that a head covering is only truly required when reciting a blessing or prayer of some sort. This also seems to be implied in OC 91:5, 6.

How do we reconcile this apparent contradiction?

This contradiction is noted by the Magen Avraham, OC 91:3 who writes that the Shulchan Aruch’s ruling in OC 2:6 is not a halachic requirement, but rather “middat chassidut,” a preferred practice for those who strive to be more pious. The ruling in OC 91, on the other hand, is the actual halacha.

The Pri Megadim (EA 3, also cited in the Biur Halacha 91) suggests that the first ruling refers to those who are walking, or are otherwise in motion, whereas the second ruling refers even to one standing in one place.

Normative halacha requires one to cover one’s head at all times (see Taz, OC 8:3), unless extenuating circumstances require one to go bareheaded.