A single server can handle web, e-mail and other services at once through one IP address. How does it know what belongs to whom? By the port.

What a port is

A port is a number the network uses to tell which service or application a given piece of traffic belongs to. While the IP address says which device, the port says which service runs on it. Picture the IP address as a building and the port as a door number inside it.

Well known ports

Some ports are fixed: web runs on port 80 (and 443 for secure HTTPS), e-mail and other services have their numbers, SSH for example port 22. Thanks to that the browser knows where to connect without you typing the port by hand.

A port and exposing a service

When you want to expose a service from your home network to the outside, you set up port forwarding on the router. This is closely tied to NAT, which hides devices behind one public address.

Physical versus logical port

Watch out for the mix-up. A “port” in this sense is a logical number in communication, not a physical socket. Physical ports are, for example, the sockets on a switch or USB connectors. The same word, two quite different meanings.

Summary

A port is the door number that tells the network which service traffic belongs to. Thanks to ports, one device can serve several services at once.

This article is part of our Computer networks overview.