One public IP address can serve a website, an SSH session, and a database at the same time. The address is identical for all three — the port number is what keeps them apart.
The analogy holds up
An IP address is a street address: it locates the machine. A port is an apartment number: it locates the service inside. A server has 65,535 usable ports, and every listening program has claimed one.
A connection is identified by four numbers — your IP and port, plus the server’s IP and port. When your browser opens a page, it picks a temporary high-numbered port for its side, while the server listens on its fixed, famous one.
The ranges are standardized:
- 0–1023: well-known ports, permanent services. On Linux and macOS, binding one requires admin rights.
- 1024–49151: registered ports, used by ordinary applications.
- 49152–65535: ephemeral ports, handed out by your OS for outgoing connections.
The port table worth knowing
| Port | Service |
|---|---|
| 22 | SSH |
| 25 | SMTP, mail sending |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 587 | Mail submission |
| 993 | IMAP over TLS |
| 3389 | Remote Desktop on Windows |
| 3306 | MySQL |
| 5432 | PostgreSQL |
| 6379 | Redis |
Where people get burned
- “Open port” does not mean “compromised.” It means something is listening. The real question is what.
- Exposing a database to the internet is the classic mistake. Redis, MongoDB, and MySQL have all been found in large numbers reachable from outside with no authentication. Firewall them.
- Localhost is not the same as everywhere. A service bound to 127.0.0.1 accepts only local connections; bound to 0.0.0.0, it accepts anything the firewall allows.
- Home servers need forwarding. Without a router rule, NAT quietly drops incoming connections.
- Scans are background noise. Someone probing your ports is normal weather, not a personal attack.
The practical rule: be able to name every port your machine is listening on. On Windows, netstat -an; on Linux, ss -tulpn. If a listening port has a service you can’t identify, you have work to do.