Description

The Communication Link Failure error refers to a problem that occurs when the database client (such as an application or a user interface) cannot establish or maintain a connection with the database server due to network or communication channel issues. You will typically encounter this error in client-server database systems, where the client application communicates with the database server to retrieve, insert, or manipulate data. 



In This Article

Common Causes 

Some of the reasons are listed below:

  • Network Connectivity Issues
    • Unstable or Disconnected Network - Weak or lost network, local hardware issues (routers, switches, etc.), or internet connectivity when accessing a remote server. 
    • Timeouts - Connection takes too long to be established or is interrupted during data insertion.

  • Database Server Availability
    • Server Down - Note running, crashed, or restarted. The client cannot communicate with it. 
    • Server Overloaded - Too busy or experiencing performance issues and cannot handle incoming requests. 
    • The database server does not accept TCP/IP connections.

  • Firewall or Security Blockage - Something between Java and DB is blocking connections (e.g., a firewall or proxy).
    • A firewall could block communication on the specific port the database server uses.
    • Issues with security certificates or encryption settings can cause communication to be blocked.

  • Incorrect Database Configuration (config.properties or JDBC Config File) 
    • The IP address or hostname in the JDBC URL is wrong.
    • The hostname in the JDBC URL is not recognized by the local DNS server.
    • The port number in the JDBC URL is missing or wrong.
    • Login credentials (username, password) are incorrect.

  • Driver Problems
    • A non-compatible version of the JDBC driver is used.
    • An incorrect JDBC driver from a vendor.


Possible Solutions

Here's a compilation of a list of solutions below. One of the following solutions can help to resolve the issue.


Notes:

For the solutions that you need to change the MySQL settings, you can refer to the following files:

  • Linux: /etc/mysql/my.cnf or /etc/my.cnf (depending on the Linux distribution and MySQL package used)
  • Windows: C:**ProgramData**\MySQL\MySQL Server 5.6\my.ini (Notice it's ProgramData, not Program Files)


1. Check Network Connectivity

Verify the connection between the client and database server is available and stable. You can verify and test the connection with ping. 


ping <ip address>
ping <domain name>
Generic


2. Verify Database Server is Running

Confirm that the database server is running and accessible. Check server logs for signs of crashes or issues, and that it is not overloaded. 

  • Restart the database service.
  • Make sure the database server is listening on the correct IP address and port.
  • If you are using a custom code/script, then check how you are closing the database connection. If required, kindly fix your code.

3. Check Firewall and Security Settings

Make certain the firewall allows traffic on the required port for database communication. Also check if security settings, such as VPNs, proxies, and SSL certificates are impacting the connection. 

  • Disable firewall and/or configure firewall/proxy to allow/forward the port.


4. Check Database Connection Details (config.properties file)

Make sure connection information is correct within the JDBC Config (config.properties) file.

  • Check port and host information in the URL. 
  • Verify username and password are correct. 
  • Refresh DNS or use an IP address in the JDBC URL instead.


5. Database Driver 

Make certain the database driver used by the client is correct and up-to-date.

  • Try a different version of the JDBC driver.
  • Try a JDBC driver from another vendor.


6. Test with a Simple Connection 

Use a simple tool or command-line utility to test the connection to the database server.


7. Check Logs and Error Messages 

Review the client and server side logs to identify any issues contributing to the failure.


8. bind-address Parameter (MySQL Configuration File)

This bind-address parameter specifies the IP Address that MySQL listens on for incoming connections. You can change the "bind-address" parameter in the configuration file:


Uncomment "bind-address" attribute or change it to one of the following IPs:
bind-address="127.0.0.1"
or,
bind-address="0.0.0.0"
Generic


9. --skip-networking option (MySQL Configuration File)

Verify if mysqld is started without the --skip-networking option. If it is, then comment out "skip-networking":


If there is a "skip-networking" line in your MySQL config file, make it comment by adding "#" sign at the beginning of that line.
Generic

10. MySQL Timeout Setting Values (MySQL Configuration File)

Increase "wait_timeout", "interactive_timeout", "connect_timeout" values in mysql db setting file my.ini. Add these lines to the MySQL config file: 


wait_timeout = number (wait_timeout=2814400)
interactive_timeout = number
connect_timeout = number
Generic

11. Make sure Java isn't translating 'localhost' to [:::1] instead of [127.0.0.1] 

This could be avoided by using one of two approaches:

  1. In a connection string, use 127.0.0.1 instead of localhost to avoid localhost being translated to :::1
  2. Run java with the option -Djava.net.preferIPv4Stack=true to force java to use IPv4 instead of IPv6. On Linux, this could also be achieved by adding an entry in /etc/profile or /home/username/.bashrc file:


export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
Generic


12. AutoReconnect Connection String Option

Append this code to your connection string at the end. Click here to learn more.


&autoReconnect=true&failOverReadOnly=false&maxReconnects=10
Generic


Additional References

For further read, please refer to these articles: