What Is a Port? Networking and Port Number Ranges Explained
A port is a numbered doorway that lets one computer run many network services at once. Learn how the well-known, registered and ephemeral ranges work.
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 aren’t random: the IANA (Internet Assigned Numbers Authority, the body that coordinates them) splits that space into three ranges, each with a different purpose. Knowing which range a port falls into tells you a lot about what it’s probably doing before you even look it up.
| Range | Name | Used for |
|---|---|---|
| 0–1023 | Well-known (system) ports | Core internet services (HTTP, SSH, DNS) |
| 1024–49151 | Registered ports | Vendor and application ports (PostgreSQL, MySQL) |
| 49152–65535 | Dynamic / private / ephemeral | Temporary ports for outbound connections |
Well-known ports (0–1023)
These are reserved for the internet’s core services. The assignments are standardized so that any machine, anywhere, knows that port 443 means HTTPS and port 22 means SSH without being told.
- 22 → SSH (remote login)
- 25 → SMTP (email)
- 53 → DNS (domain name lookups)
- 80 → HTTP (web)
- 443 → HTTPS (secure web)
On Unix systems, binding to a port below 1024 traditionally requires elevated privileges, which is why running a web server on port 80 directly on Linux needs sudo, while a dev server on 3000 does not. This is a deliberate safety measure: it stops an unprivileged program from impersonating a standard system service. macOS relaxed the rule in Mojave (10.14): a regular user can bind a low port on all interfaces (0.0.0.0), but binding one to a specific address such as 127.0.0.1 still requires root.
Registered ports (1024–49151)
These are for applications that asked IANA to reserve a number, plus the vast informal middle ground that developers use day to day. Any user-level program can bind here without special privileges, which is why nearly every dev tool defaults somewhere in this range.
- 3000 → Node / React dev servers
- 3306 → MySQL
- 5173 → Vite
- 5432 → PostgreSQL
- 6379 → Redis
- 8080 → alternate HTTP / proxies
You can look up any specific number in the port reference.
Dynamic / ephemeral ports (49152–65535)
This top band is never assigned to a fixed service. Instead, the operating system hands these ports out temporarily. When your browser connects to a website, it grabs a free port from this range as the return address for that one connection, then releases it when the connection closes.
It’s completely normal to see dozens of them open at once. They’re outbound connections in progress, not services waiting for traffic. macOS uses 49152–65535 by default, matching the IANA recommendation (Linux historically starts lower, around 32768). You can check your Mac’s range with:
sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last
Using the range as a first filter
When you’re inspecting your own machine and trying to make sense of what you see, the range is a fast first filter:
- A low port (under 1024) in the
LISTENstate is almost always a recognizable system or server service. - A mid port (1024–49151) listening is usually a development tool or a registered application.
- A high port (49152+) is almost always a temporary outbound connection, not something you started or need to worry about.
That mental model saves you from chasing “mystery” ports that are just your browser doing its job.
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 “address 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 Address 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.