`Bind for 0.0.0.0:5432 failed: port is already allocated`
BeginnerTroubleshootingNetworking, DNS and Compose
Answer
Likely causes → Another container or host process uses that port.
Diagnose →
sudo ss -tlnp | grep 5432
docker ps --format '{{.Names}} {{.Ports}}' | grep 5432
Fix → Stop the other process, or map another host port (-p 5433:5432), or drop the publish.
Prevent → Don't publish DB ports; use internal networks.
More on Networking, DNS and Compose
`curl: (7) Failed to connect to localhost port 8080: Connection refused` after `docker run -p 8080:80 nginx`.BeginnerContainers cannot reach the internet: `Temporary failure in name resolution`Advanced`ping` works to IPs but DNS names fail on the default bridge: `ping: bad address 'db'`Beginner`getaddrinfo ENOTFOUND db` in a Compose app.BeginnerCompose: `service "api" depends on undefined service "db"`BeginnerCompose: `yaml: line 14: mapping values are not allowed in this context`Beginner