Network Port
A network port is a 16-bit number (0 to 65535) that identifies a specific service on a host within a TCP or UDP connection. Ports let one IP address serve many services at once.
Understanding Network Ports
What Is a Network Port?
If an IP address is a building's street address, a port is the apartment number. One server at 10.0.1.50 can run nginx on port 443 and PostgreSQL on port 5432 at the same time, and the kernel delivers each connection to the process listening on the destination port.
Server 10.0.1.5022 sshd80 nginx (HTTP)443 nginx (HTTPS)4000 payment-api5432 postgresql6379 redis Incoming: 203.0.113.45:52341 -> 10.0.1.50:443 client IP:ephemeral port server IP:service portPort Ranges
0-1023 Well-known: standard services (22 SSH, 80 HTTP, 443 HTTPS, 53 DNS) Binding normally requires root or the right capability1024-49151 Registered: 3306 MySQL, 5432 PostgreSQL, 6379 Redis, 9090 Prometheus49152-65535 Dynamic range defined by IANA. Linux picks client ports from its own range, by default 32768-60999 (check yours below)cat /proc/sys/net/ipv4/ip_local_port_rangeHow to See and Test Ports
ss -tulpn # listening sockets and owning processss -tulpn | grep :8080 # who has port 8080sudo lsof -i :8080 nc -zv 10.0.1.50 5432 # is the remote port reachablenc -zv -w3 10.0.1.50 5432 # with a 3 second timeout ssh -L 5433:localhost:5432 rahul@10.0.1.50 # forward a remote DB to localhost:5433Troubleshooting Ports
| Symptom | Command | What to Check |
|---|---|---|
| Port already in use | ss -tulpn | grep :PORT |
Another process bound |
| Connection refused | ss -tlnp on server |
Nothing listening |
| Connection times out | Firewall and security group | Packets dropped upstream |
| Cannot bind below 1024 | Run as root or use a capability | Privileged port rule |
TipRead the bind address.
127.0.0.1:5432is reachable only from the same host, while0.0.0.0:5432accepts connections on every interface.
Common MistakeConfusing "open in the security group" with "a process is listening". Refused usually means nothing is listening, while a timeout usually points to filtering. Check
ss -tlnpfirst.
SecurityDo not expose databases such as PostgreSQL or Redis on
0.0.0.0without firewall rules limiting the source addresses.
Frequently Asked Questions
Why are ports below 1024 restricted?
They are the well-known service range. Requiring privilege to bind them stops an unprivileged user from impersonating a standard service such as SSH or HTTP. Apps often listen on a high port and let a reverse proxy handle 80 and 443.
What is the difference between a refused connection and a timeout?
Refused means the host answered but no process is listening on that port. A timeout means packets are being dropped or never arrive, usually because of a firewall or routing issue.
What is an ephemeral port?
It is a temporary source port the operating system assigns to an outgoing connection, such as your browser connecting to port 443. Linux picks it from a configurable range.