Interview Prep/Networking/Connectivity: refused, timed out, no route

`nc: connect to db.internal port 5432 (tcp) failed: Connection refused`, yet PostgreSQL is running.

BeginnerTroubleshootingConnectivity: refused, timed out, no route
Answer

Likely causes → listen_addresses = 'localhost' in postgresql.conf, Postgres listening on a different port, or you resolved to a different host than you think.

Diagnose →

sudo ss -ltnp | grep postgres
sudo -u postgres psql -c 'show listen_addresses; show port;'
getent hosts db.internal

Fix → Set listen_addresses = '*' (or the private IP), restart, then allow the client in pg_hba.conf. Note that a pg_hba.conf miss gives no pg_hba.conf entry for host, not "refused".

Prevent → Template DB configs and verify from an app host after every change.

All Networking questions Roadmap: Networking for DevOps

More on Connectivity: refused, timed out, no route