"lodging for ships; sheltered recess in a coastline," early 12c., a specialized sense of Middle English herberwe "temporary dwelling place, quarters, lodgings; an inn; the camp of an army in the field," probably from Old English here-beorg (West Saxon), *here-berg (Anglian) "lodgings, quarters," from Proto-Germanic compound *harja-bergaz "shelter, lodgings," from *heri "army, host" (see harry (v.)) + *burzjan- "protection, shelter" (from PIE root *bhergh- (1) "to hide, protect"). Perhaps modeled on Old Norse herbergi "room, lodgings, quarters."
Old English herebeorgian "take up quarters, lodge, shelter oneself" (cognate with Old Norse herbergja, Old High German heribergon, Middle Dutch herbergen), verbal formation from here-beorg "lodgings, quarters" (see harbor (n.)). Meaning "give shelter to, protect" is from mid-14c. Figuratively, of thoughts, etc., from late 14c. Related: Harbored; harboring.