Site icon codippa

How to resolve “com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure java.net.ConnectException: Connection refused” error

If you are facing this error, then it indicates that you are connecting to a MySQL database from a java application either directly using JDBC or through a framework such as Hibernate, iBatis or Spring.
This post will list out various probable causes for this error and the steps that you may follow for its resolution.
Reason
In order to connect to a MySQL database from a java application, either a connection string of the format jdbc:mysql://<databaseip>:<port>/databasename is used or a properties file that specifies different connection parameters such as database server URL, port, database name etc. is utilized.

Error clearly tells us that the application is trying to connect to a specified database but it could not.
There may be several reasons for this as listed below.

Solution
For resolving the error, follow the below check list.

There are bright chances that after following above steps, the error will be resolved.
If any other solution worked for you, do not forget to mention it in the comments below.
Hit the clap!!!

Exit mobile version