Error: SQLstate[Hy000] [2002] No Connection Could Be Made Because the Target MAChine Actively Refused It

ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it

If the WAMP icon is Orange then one of the services has not started.

In your case it looks like MySQL has not started as you are getting the message that indicates there is no server running and therefore listening for requests.

Look at the mysql log and if that tells you nothing look at the Windows event log, in the Windows -> Applications section. Error messages in there are pretty good at identifying the cause of MySQL failing to start.

Sometimes this is caused by a my.ini file from another install being picked up by WAMPServers MySQL, normally in the \windows or \windows\system32 folders. Do a search for 'my.ini' and 'my.cnf' and if you find one of these anywhere outside of the \wamp.... folder structure then delete it, or at least rename it so it wont be found. Then restart the MySQL service.

php: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it

didn't you say your mysql port is 3306:

$db = new PDO("mysql:host=".DBHOST.";port=8889
//------------------------------------------^

this might help:

$db = new PDO("mysql:host=".DBHOST.";port=3306

SQLSTATE[HY000] [2002] No Connection Could Be Made

change port to DB_PORT=3306 the
run the following commands

1.php artisan config:clear

2.php artisan cache:clear



Related Topics



Leave a reply



Submit