Appendix A — Default Ports Cheat Sheet
A port is a numbered door on a server (Chapter 3 explains the city version). The number tells you what usually answers there. It does not prove what is answering, because any program can bind any free number. Use this page to answer two questions: what is probably behind this port, and should the street be able to knock on it?
Every row carries one of three verdicts:
- ✅ Safe to expose. Built to face the internet, usually behind TLS and a proxy.
- ⚠️ Only if intended and hardened. There is a real reason to open it, and you have locked it down.
- ❌ Never expose. Keep it private. Bind it to
127.0.0.1, or reach it over Tailscale (Chapter 16).
A Proto of tcp, udp means both transports use that number. They are separate doors, and a program has to listen on each one on its own.
Ports by family
Section titled “Ports by family”Remote access and file transfer
Section titled “Remote access and file transfer”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 20/21 | tcp | FTP | File transfer in cleartext. 21 is the control channel, 20 the data channel in active mode. | ❌ Never. Use SFTP over 22 instead. |
| 22 | tcp | SSH | Encrypted shell, plus SFTP and tunnels. See Chapter 6. | ⚠️ Key-only logins, no root, rate-limited. For admin, Tailscale is the better door. |
| 23 | tcp | Telnet | Remote login with no encryption at all. | ❌ Never. Anyone on the path reads your password. |
| 2049 | tcp, udp | NFS | Network file shares. | ❌ Never. Trust is mostly by IP address, which is no trust at all. |
| 3389 | tcp | RDP | Windows remote desktop. | ❌ Never. Scanners probe it all day. |
| 5900 | tcp | VNC | Remote screen sharing. 5900 is display 0, 5901 display 1, and so on. | ❌ Never. |
Network plumbing
Section titled “Network plumbing”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 53 | tcp, udp | DNS | Name lookups. UDP for ordinary queries, TCP for large answers and zone transfers. | ⚠️ Authoritative server: yes, that is its job. Open recursive resolver: never, because attackers use it for amplification. |
| 67/68 | udp | DHCP | Server listens on 67, client on 68. Works by broadcast on the local network. | ❌ Never. It is a LAN protocol and does not cross the internet. |
| 123 | udp | NTP | Clock sync. | ❌ Keep it outbound only. Public NTP servers get abused for amplification. |
| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 25 | tcp | SMTP | Server-to-server mail delivery. | ⚠️ Only if you run a mail server. Many cloud providers block outbound 25 by default. |
| 110 | tcp | POP3 | Legacy mail download. | ⚠️ Legacy. Prefer 995. |
| 143 | tcp | IMAP | Mail sync, cleartext unless upgraded with STARTTLS. | ⚠️ Prefer 993. |
| 465 | tcp | SMTPS | Mail submission with TLS from the first byte. | ⚠️ Only for your own mail server and its clients. |
| 587 | tcp | Submission | Mail clients sending mail, upgraded with STARTTLS. | ⚠️ Only for your own mail server and its clients. |
| 993 | tcp | IMAPS | IMAP inside TLS. | ⚠️ Fine for your own mail server. |
| 995 | tcp | POP3S | POP3 inside TLS. | ⚠️ Fine for your own mail server. |
Mail gets its own story in Chapter 13. Most of the time you want a provider to hold these doors, not you.
| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 80 | tcp | HTTP | Plain web traffic. Mostly it exists to redirect you to 443 and to answer certificate challenges. | ✅ Yes, for redirects and ACME challenges. Serve nothing else on it. |
| 443 | tcp, udp | HTTPS | Web over TLS. The UDP side carries HTTP/3 over QUIC. See Chapter 9. | ✅ Yes. This is the front door. |
| 8080 | tcp | Alternate HTTP | Tomcat, Jenkins, and many proxies pick it by default. | ⚠️ Only behind a proxy you control, never as a public door. |
| 8443 | tcp | Alternate HTTPS | The TLS twin of 8080. | ⚠️ Same rule as 8080. |
Dev servers
Section titled “Dev servers”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 3000 | tcp | Node and Next.js dev | The default for most JavaScript dev servers. Every tutorial uses it. | ❌ Never raw. Bind it to 127.0.0.1 and let the proxy speak for it. |
| 4000 | tcp | Assorted dev servers | Phoenix and some static-site tools use it. | ❌ Never raw. Same rule as 3000. |
| 5000 | tcp | Flask dev | On recent macOS versions, AirPlay Receiver can hold this port, so your app may refuse to start. | ❌ Never. |
| 5173 | tcp | Vite dev | Vite’s default. | ❌ Never. |
| 8000 | tcp | Python and Django dev | python -m http.server and runserver both land here. |
❌ Never. |
| 9000 | tcp | Assorted | Often PHP-FPM or MinIO. The number tells you little, so find out what it is first. | ❌ Never raw. |
Databases and caches
Section titled “Databases and caches”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 1433 | tcp | SQL Server | Microsoft’s database door. | ❌ Never. |
| 3306 | tcp | MySQL, MariaDB | The MySQL family door. | ❌ Never. |
| 5432 | tcp | PostgreSQL | Your Postgres, if you run one. | ❌ Never. In Compose, leave the database off ports: so only sibling containers reach it. |
| 6379 | tcp | Redis | In-memory store. Old setups ran with no password. | ❌ Never. Open Redis on a public IP has been hijacked again and again, a widely told story. |
| 9200 | tcp | Elasticsearch HTTP | Search and index API. | ❌ Never. Open clusters have been wiped by attackers, as widely reported. |
| 11211 | tcp, udp | Memcached | Cache. | ❌ Never. Its UDP side was abused for huge amplified attacks. |
| 27017 | tcp | MongoDB | Document database. | ❌ Never. |
Brokers and admin UIs
Section titled “Brokers and admin UIs”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 1883 | tcp | MQTT | Message broker for devices and sensors. Plain MQTT is cleartext. | ❌ Never raw. If devices must reach it from outside, use MQTT over TLS on 8883 with auth. |
| 5672 | tcp | AMQP | RabbitMQ’s door for apps and workers. | ❌ Never. Apps reach it on the private network or over a tunnel. |
| 15672 | tcp | RabbitMQ management | The web admin UI for RabbitMQ, with its own login. | ❌ Never. Tailscale or an SSH tunnel is the right door. |
| 9090 | tcp | Prometheus, Cockpit | Prometheus serves its UI and API here by default. Cockpit, the Linux admin panel, uses it too. | ❌ Never raw. Both hand out admin power. |
Containers and clusters
Section titled “Containers and clusters”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 2375 | tcp | Docker API, plain | The Docker daemon’s API with no TLS. Whoever reaches it can start a privileged container and own the host. | ❌ Never. Not even on a private network without a firewall. |
| 2376 | tcp | Docker API, TLS | The same API behind mutual TLS. | ⚠️ Only with client certificates, and preferably over Tailscale. |
| 6443 | tcp | Kubernetes API | The control plane door of a cluster. Every kubectl call lands here. |
⚠️ Only if you run the cluster and restrict it by IP or VPN. Never open it to the whole internet. |
Tunnels and VPNs
Section titled “Tunnels and VPNs”| Port | Proto | Service | What it is | Safe to expose? |
|---|---|---|---|---|
| 51820 | udp | WireGuard | The default WireGuard port. WireGuard stays silent toward anyone without the right key. | ⚠️ Yes, if you run WireGuard. Opening it is the point. |
| 41641 | udp | Tailscale | Tailscale’s usual UDP port for direct links. Hedge: it can pick another port. | ❌ No need to open it. Tailscale punches through NAT or relays when it must. |
| 7844 | tcp, udp | cloudflared | The outbound edge connection a Cloudflare Tunnel makes. Hedge: the number has changed over time, so check current docs. | ❌ Do not open it inbound. The connector dials out, so nothing listens on your side. |
Tunnels get their own story in Chapter 16 and Chapter 17.
Port ranges
Section titled “Port ranges”The numbers run from 0 to 65535, and they fall into three bands. The bands describe who usually uses a number. They do not say who is allowed to.
| Band | Range | What it means |
|---|---|---|
| Well-known | 0 to 1023 | Standard services. On Linux, binding here needs root or the CAP_NET_BIND_SERVICE capability. |
| Registered | 1024 to 49151 | Assigned loosely to vendors and apps. Your 3000, 5432, and 6379 live here. |
| Dynamic | 49152 to 65535 | Client-side doors, picked for you when your machine connects out. |
Ephemeral ports are the short-lived client ports your OS hands out for outbound connections. On Linux the default range is roughly 32768 to 60999. Check yours with cat /proc/sys/net/ipv4/ip_local_port_range. That range overlaps the registered band, so a port you choose in the 30000s or 40000s can collide with a client socket that got there first. macOS and Windows pick their own ranges, so check there too.
How to see what’s listening
Section titled “How to see what’s listening”Run these on your own server or laptop. The question is always the same: which program holds which door, and on which address?
| Command | What it shows |
|---|---|
ss -tlnp |
TCP sockets in LISTEN state, numeric, with the owning process. Add sudo to see other users’ processes. |
ss -ulnp |
UDP sockets. UDP has no LISTEN state, so you see every bound socket. |
lsof -iTCP -sTCP:LISTEN -nP |
The same TCP question on macOS, where ss is usually missing. |
nc -vz 203.0.113.10 22 |
Can I connect from here? A connect test, not a listing. |
nmap -p 3000 127.0.0.1 |
A port scan. Point it only at machines you own. |
Read the Local Address column first. It holds the bind address and the port together.
$ sudo ss -tlnpState Recv-Q Send-Q Local Address:Port Peer Address:Port ProcessLISTEN 0 511 127.0.0.1:3000 0.0.0.0:* users:(("node",pid=4411,fd=21))LISTEN 0 244 10.0.0.5:5432 0.0.0.0:* users:(("postgres",pid=902,fd=6))LISTEN 0 4096 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=701,fd=3))The Node app is private to the box. Postgres answers only on the private network address. SSH listens on every interface, which is normal for SSH and why the key-only rules in Chapter 6 matter. The address decides the audience, and the port decides the door.
Bind addresses: who can knock
Section titled “Bind addresses: who can knock”A service does not just pick a port. It picks an address to listen on, and that choice decides who can reach it at all. The same port number can be private on one line and public on the next.
| Bind address | Listens on | Who can reach it | Use it when |
|---|---|---|---|
127.0.0.1 |
IPv4 loopback only | This machine only | A database, a dev server, or an admin UI that a local proxy will front |
::1 |
IPv6 loopback only | This machine only | The IPv6 twin of the line above |
10.0.0.5 |
One interface, the private address | Your private network | Services that only your other boxes should use |
100.101.102.103 |
One interface, the tailnet address | Your tailnet devices | Admin tools you want behind Tailscale (Chapter 16) |
0.0.0.0 |
Every IPv4 interface | Anyone who can route to any of them | Public services behind a firewall you trust |
:: |
Every IPv6 interface | Anyone on any IPv6 interface | The IPv6 twin of 0.0.0.0, and on many Linux boxes it also takes IPv4 |
Three rules cover most cases:
- Bind to loopback by default. If only the proxy on the same box needs the app,
127.0.0.1:3000is the whole story. Nothing on the street can reach it, even if the firewall is wide open. 0.0.0.0is a yes, not a default. Many frameworks choose it when you do nothing, and thenpm run devoutput will cheerfully sayhttp://0.0.0.0:3000. Check thessoutput, not the tutorial.- Docker is a special guard. Published container ports can bypass the host firewall rules you wrote with
ufw, because Docker writes its own rules. Treat a-p 5432:5432as public, whatever your firewall says. The section below shows how to bind it to loopback.
127.0.0.1:3000 reachable from this box only (the proxy's view)10.0.0.5:5432 reachable from your private network only0.0.0.0:443 reachable from anywhere the route allowsDocker -p: where the published door opens
Section titled “Docker -p: where the published door opens”-p publishes a container port on the host. The shape is [host address:]host port:container port[/protocol]. Leave out the address and Docker binds to 0.0.0.0, which is every interface.
| Form | Example | What it does |
|---|---|---|
| Port pair | -p 8080:80 |
Host port 8080 on every interface to container port 80. Public by default. |
| Loopback | -p 127.0.0.1:8080:80 |
Same ports, reachable from this box only. The safe default for an app behind a proxy. |
| Private IP | -p 10.0.0.5:5432:5432 |
Reachable from your private network only. |
| Same number | -p 3000 |
Container port 3000 on a random host port. You find it with docker port. |
| UDP | -p 51820:51820/udp |
UDP instead of TCP. The protocol is part of the spec. |
| Range | -p 8000-8010:8000-8010 |
A block of ports mapped one to one. |
| Expose only | --expose 3000 |
Documents the port for other containers on the same network. It publishes nothing to the host. |
The Compose ports: key takes the same forms. Quote them, so YAML does not read 22:22 as a base-60 number:
services: app: image: hello-pipes:latest ports: - "127.0.0.1:3000:3000" # the proxy reaches it; the street does not db: image: postgres:16 # no ports: block at all. Other containers reach it by name.If you see port is already allocated, another process or container already holds that host address and port. Look at it with ss -tlnp, then read Appendix E for the full decoder.
Book 2 of a series. Book 1: The Glue.