Pcornel
Databases · Database Troubleshooting

Connection Refused and Timeouts

Cheat sheet · https://pcornel.dk/topic.php?topic=6194

Back to the Topic

Answer

Connection refused means nothing listens on that address/port (or it rejects); timeout means packets are dropped (firewall, routing) or the server is overloaded.

Remember

Check listening address (localhost only?), port, firewall, and the server's connection limit. Then authentication.

First checks

  • nc -vz <host> <port> — first check for this topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -S <server> -Q "SELECT @@VERSION" — SQL Server reachable and version

Verify in this order

client → DNS → TCP to port → server accepts → auth

Where it usually breaks

A server listening only on 127.0.0.1 refuses remote connections.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6194

Confirmation

Confirm action

Continue?