What are ports, and which common ports should a DevOps engineer know?
BeginnerConceptNetworking basics for DevOps
Answer
In one line: A port is a number (0–65535) that identifies a specific service on a machine, so one server with one IP address can run many services — the IP finds the machine, the port finds the application.
Port ranges:
- 0–1023: well-known ports (system services); binding to them on Linux traditionally needs root privileges.
- 1024–49151: registered ports (many applications).
- 49152–65535: dynamic/ephemeral ports (used temporarily by clients).
Common ports to know:
| Port | Service |
|---|---|
| 22 | SSH |
| 25 / 587 | SMTP (email sending) |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 3306 | MySQL |
| 5432 | PostgreSQL |
| 6379 | Redis |
| 27017 | MongoDB |
| 9092 | Kafka |
| 2379–2380 | etcd |
| 6443 | Kubernetes API server |
| 10250 | kubelet |
| 8080 | Common for apps / Jenkins |
| 9090 | Prometheus |
| 3000 | Grafana (and many Node.js apps) |
| 9100 | Node exporter |
Useful commands:
ss -tulpn # which ports are listening on this machine, and by which process
sudo lsof -i :8080 # what is using port 8080
nc -zv db.internal 5432 # can I reach this TCP port?
curl -v http://localhost:8080/health
DevOps relevance:
- Security groups / firewalls / NetworkPolicies — open only the ports you need, to the sources that need them. Never expose 22, 3306 or 5432 to
0.0.0.0/0. - Containers —
EXPOSE 8080in the Dockerfile;-p 80:8080maps host port 80 to container port 8080. - Kubernetes —
containerPort, ServiceportandtargetPortmust line up. - "Address already in use" errors mean another process is using the port.
Tip for interviews: mention that port vs targetPort mismatches in Kubernetes Services are a very common cause of "connection refused".
More on Networking basics for DevOps
What happens when you type a URL in the browser and press Enter?BeginnerWhat is DNS, and what are common DNS record types?BeginnerWhat is the difference between TCP and UDP?BeginnerWhat is the difference between a forward proxy and a reverse proxy?BeginnerWhat is a CDN, and how does it help applications?BeginnerWhat are VPCs, subnets and security groups?Beginner