Pod container binds host port — address already in use
Pod in CrashLoopBackOff with bind: address already in use
Focused incident mode — strips away everything but this runbook.
Symptoms
- Pod in CrashLoopBackOff with bind: address already in use
- Events show Failed to create pod sandbox due to bind port
- Application starts but exits immediately with EADDRINUSE
hostPort should almost never be used in production. Use a Service of type NodePort or LoadBalancer instead. hostPort limits scheduling to one pod per node for that port.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Crash logs
kubectl logs <pod> -n <namespace> --previoushostPort usage
kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.containers[*].hostPort}'
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- hostPort is set and two pods are scheduled on the same node
- Crash logs show EADDRINUSE
Confirm before fixing
kubectl get pods -n <namespace> -o wide | grep <node>List pods on the conflicting node
Fix
kubectl patch deployment/<deploy> -n <namespace> --type merge -p '{"spec":{"template":{"spec":{"containers":[{"name":"<c>","ports":[{"containerPort":8080}]}}}}}'Remove hostPort and use a Service to expose the port instead
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
kubectl logs <pod> -n <namespace> --previousConfirm EADDRINUSE
kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.containers[*].hostPort}'Check hostPort usage
kubectl get pods -n <namespace> -o wide | grep <node>Find the conflicting pod on the same node
kubectl patch deployment/<deploy> -n <namespace> --type merge -p '{"spec":{"template":{"spec":{"containers":[{"name":"<c>","ports":[{"containerPort":8080}]}}}}}'Remove hostPort; expose via Service instead
Prevention
- Avoid hostPort in manifests; use containerPort + Service.
- If hostPort is absolutely necessary, set topology spread constraints to avoid co-location.
- Run a lint check (e.g., kubeval/kube-linter) that flags hostPort usage.
- Document the specific use case for hostPort and require explicit approval.
Related runbooks
Same stack, same failure family — worth a skim.
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.