What Is a Port? Networking Explained Simply
A network port is a numbered doorway that lets one computer run many network services at once. Here's what ports are, why they exist, and how the numbering works, with real examples.
Your Mac has one IP address but runs dozens of network services at the same time, a web browser, a mail client, a dev server, file sharing, AirPlay. So how does incoming data know which program it belongs to? The answer is ports.
The apartment building analogy
Think of an IP address as a building’s street address. It gets data to the right machine, but a building has many apartments. The port number is the apartment number: it tells the data which specific program inside the machine to deliver to.
- IP address → which computer (e.g.
192.168.1.5) - Port number → which program on that computer (e.g.
443for the web server)
Together they form a socket: 192.168.1.5:443. That pair uniquely identifies one endpoint of a network conversation.
Why ports exist
Without ports, a computer could only run one network service at a time. You couldn’t browse the web while checking email while running a local database, all that traffic would arrive at the same address with no way to sort it.
Ports solve this by giving each service its own number. When a packet arrives, the operating system reads the destination port and hands the data to whichever program is listening there. One IP, thousands of possible ports, many services running side by side.
How port numbers work
A port number is a 16-bit integer, which means it ranges from 0 to 65535, giving 65,536 possible ports. They’re split into three ranges by the IANA (the body that coordinates them):
| Range | Name | Used for |
|---|---|---|
| 0–1023 | Well-known ports | Standard services (HTTP, SSH, DNS) |
| 1024–49151 | Registered ports | Apps that registered a number (PostgreSQL, MySQL) |
| 49152–65535 | Dynamic / ephemeral | Temporary ports for outbound connections |
A handful you’ll recognize:
- 80 → HTTP (web)
- 443 → HTTPS (secure web)
- 22 → SSH (remote login)
- 53 → DNS (domain name lookups)
- 3000 → common local dev server default
- 5432 → PostgreSQL
We go deeper on the ranges in Port Number Ranges Explained, and you can look up any specific number in the port reference.
Listening vs. connecting
A port can be doing one of two things:
- Listening: a program has claimed the port and is waiting for incoming connections. A web server listens on 443.
- Connecting: a program reaches out to a port on another machine. Your browser connects to a website’s port 443, using a temporary ephemeral port on your end as the return address.
This is why you’ll see two kinds of entries when you inspect your ports: a few services in the LISTEN state, and many short-lived outbound connections using high-numbered ephemeral ports.
TCP ports vs. UDP ports
Port numbers exist separately for each transport protocol. Port 53 on TCP and port 53 on UDP are technically different ports, and DNS actually uses both. Most services pick one protocol: web traffic is TCP, DNS queries are usually UDP. See TCP vs UDP for how the two differ.
“Only one program per port”
Here’s the rule that causes the most confusion: on a given protocol, only one program can listen on a port at a time. If a process is already bound to port 3000 and another tries to grab it, the second one fails with an error like address already in use or EADDRINUSE.
That’s why “port already in use” errors happen so often in development, two things want the same number. The fix is to find what’s holding the port and either stop it or move your app to a different port. See Port already in use on Mac for the walkthrough.
How to see the ports on your own Mac
The terminal command is:
sudo lsof -iTCP -sTCP:LISTEN -n -P
This lists every program currently listening for connections, the port it owns, and its process ID.
See your ports without the terminal
Portie turns that command into a live window. It shows every open port on your Mac, the app that owns it, the protocol, and the connection state, refreshed automatically every 3 seconds. No commands to memorize.
Local monitoring is free. The $8.99 one-time unlock adds one-click process termination and remote port scanning for other hosts on your network. Download Portie to see what your Mac is actually listening on.