Walker Holahan Walker Holahan - 2 months ago 11
MySQL Question

Issue connecting to port 3306 for mysql application

The Java application I am working with is supposed to write its resulting data to a mysql database, but whenever I run it, I get the following exception:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

With the following cause:

Caused by: java.net.ConnectException: Connection refused

Naturally, my next step was to test the port that mysql was attempting to connect on (3306).

$ telnet localhost 3306
telnet: Unable to connect to remote host: Connection refused

My next step was to see if port 3306 was listening at all.

$ netstat -an|grep 3306
tcp 0 0* LISTEN

So in summary, the port is listening but not accepting connections?
I must admit, I do not know a whole lot about this, but does anybody know what is going on here?


I figured it out. I needed to connect to mysql externally, but my program was trying to access it locally.