The firm connection between ports and harbors arises from the human activity to enhance the convenience of natural havens used for shipping purposes. Early sea traders used bays, islands, and river mouths to protect themselves from violent weather and currents. When they found a safe place suitable for trade, they would develop that place for future trading.
In a port, the specific place where goods and people are unloaded from a boat is generally referred to as the docks. The entire city or town, which has been developed around the docks, is the port:
OED
NOUN
A town or city with a harbor where ships load or unload, especially one where customs officers are stationed.
Emphasis mine
Which came first, the city or the port? In 2010, Port Shanghai, China, overtook Singapore and Hong Kong as the busiest cargo port in the world. It was just a tiny agricultural village at the mouth of the Yangtze river until the Qing Dynasty developed it as a port between 1600 and 1900. It was a very desirable port for sea traders for two reasons:
- The natural shelter of the Hangzhou Bay provided safe haven for ships.
- The navigable Yangtze river provided easy access to interior commerce.
Shanghai

Dover

The dock infrastructure and the port city of Dover, England, the busiest passenger port in the world, also grew together near a large safe natural haven. In fact, most large coastal cities can attribute their current location to the maritime convenience of early sea traders, who chose safe natural havens for loading and unloading their cargo and passengers.
The etymology of port is rooted in the image of moving from one place to another:
"harbor,"
Old English port "harbor, haven," reinforced by Old French port
"harbor, port; mountain pass;"
Old English and Old French words both from Latin portus "port,
harbor," originally "entrance, passage," figuratively "place of
refuge, assylum,"
from PIE *prtu- "a going, a passage," from root **per*- (2) "to lead,
pass over"
(cognates: Sanskrit parayati "carries over;" Greek poros
"journey, passage, way," peirein "to pierce, run through;" Latin
porta "gate, door," portare "passage," peritus
"experienced;" Avestan peretush "passage, ford, bridge;"
Armenian hordan "go forward;" Welsh rhyd "ford;" Old Church
Slavonic pariti "to fly;" Old English faran "to go, journey,"
Old Norse fjörðr "inlet, estuary").
Eventually, port becomes a synonym for harbor:
OED
1.1 A harbor:
Port is a sensible synonym for harbor because the locations that serve to move goods between land and sea have natural land structures providing safe haven for ships to load and unload. Later, manmade port structures enhance the safety and convenience of the natural haven, turning it into a harbor:
OED
- A place on the coast where ships may moor in shelter, especially one protected from rough water by piers, jetties, and other artificial
structures:
Bays, islands and river mouths may provide natural protection and convenience for sea traders, but the word harbor emphasizes the manmade enhancements.
The etymology is rooted in the image of lodging and shifts to refuge:
"lodging for ships,"
early 12c., probably from Old English herebeorg "lodgings, quarters,"
from here "army, host" (see harry) + beorg "refuge, shelter" (related
to beorgan "save, preserve;" see bury);
perhaps modeled on Old Norse herbergi "room, lodgings, quarters."
Sense shifted in Middle English to "refuge, lodgings," then to "place
of shelter for ships."
This sense of safe place is included in the formal definition and is very much connected to the metaphorical use of harbor.
1.1 A place of refuge:
Our orphanage is a harbor for children in distress.
OR
This house was a welcome harbor for weary souls.
Although they are deeply interconnected by the practical activities of shipping, the word port emphasizes the commercial element of moving people and goods from one place to another, while the word harbor emphasizes the safe place for ships to stay. The two ideas fit hand in glove.