Mysql No connection could be made because the target machine actively refused it

Your MySQL server is only accepting connections on *nix socket (/var/run/mysqld/mysqld.sock if you're running Ubuntu) or for localhost only.

You have to edit your my.cnf (on Ubuntu again is located in /etc/mysql/my.cnf) and change the following:

bind-address = 0.0.0.0

And comment out the following

#skip-networking

Finally restart MySQL.

Be careful with that, if your MySQL machine is accessible from public Internet will be accepting connections from everybody!


Even if this is not your case, I will add the answer here, because the message for this bug is the same.

There is a bug in MySQL server when you have some alias for localhost in c:\Windows\System32\Drivers\etc\hosts, MySQL server is unable to accept connection to localhost.

Remove the alias and MySQL Server will start to accept connections to localhost.


I do not have the #skip-networking option.

I resolved it by hashing out the bind address line (See 3rd line below).

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.**
#bind-address       = 127.0.0.1

I solved just adding the port in bind-address like that: 127.0.0.1:3388