If you get a SQLException: Connection refused
or Connection timed out
or a MySQL specific CommunicationsException: Communications link failure
, then it means that the DB isn't reachable at all. This can be from one or more of the following causes:
- IP address or hostname in JDBC URL is wrong.
- The hostname in the JDBC URL is not recognized by the local DNS server.
- Port number is missing or wrong in JDBC URL.
- DB server is down.
- DB server doesn't accept TCP/IP connections.
- DB server has run out of connections.
- Something in between Java and DB is blocking connections, e.g. a firewall or proxy.