I know there are many people already asked this , but this people mostly forgot password of blocked by firewall which I have none of this situations .
I am developing with php , and I need to connect to remote database to let all my team work on it .
localhost was just going fine , but when I tried to switch it gave me this error
No connection could be made because the target machine actively refused it.
and this is my code where I want to connect to .nf.biz database :
$db=mysqli_connect($host,$user,$password,$db_name,3306);
You can try below solution: You might have a firewall rule in the way, or are trying to run it through a proxy without having the proxy up and running. The easiest way to check would be to disable your firewall or proxy and try again. Disable proxy at web.
“No connection could be made because the target machine actively refused it.” Generally, it happens that something is preventing a connection to the port or hostname. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that specific port.
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!
I solved just adding the port in bind-address like that: 127.0.0.1:3388
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With