MySQL error message SQLSTATE[HY000] [2002] Connection refused

Linode Staff

I am experiencing a MySQL related error that seems to preventing me from importing data to the server. I'm trying to import my Amazon products to my webiste using the Amazon Magento Connect add-on.

The Error code I am getting is SQLSTATE[HY000] [2002] Connection refused.

1 Reply

I did some research on the SQLSTATE[HY000] [2002] Connection refused error and I have some theories that I hope lead you in the right direction.

A common occurence with this error message seems to be related to the port number it is trying to connect to. For instance, in this post I found on StackOverflow, a user was able to resolve their issue by changing the port from 8888 to 8889. The commmand they used:

$conn = new PDO("mysql:host=$servername;port=8889;dbname=AppDatabase", $username, $password); 

Another possible solution in that post talks about changing the host to use the IPv4 loopback address: 127.0.0.1 instead of using the IPv6 ::1.

I came across an additional post on StackOverflow that goes over a similiar issue, but the end-user was using MariaDB. Their resolution seemed to also be associated with the port number not being correct. Basically, these two posts are showing how important it is to make sure the correct port numbers are being used to establish a connection to your database.

If the above information does not bring you to a solution, you can try looking at your log files and see if you notice any errors involving mysql, such as the service not starting or if there are out of memory issues.

grep oom /var/log/*

While researching this error, I did come across this post on StackExchange where a user's console was running ouf ot memory and MySQL was being terminated.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct