SQLSTATE[HY000] [2002] Connection refused


Hello I just put my website on the server of the company and I have this error

SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from `users` where `email` = edi@test.fr)

In local it works very well
Here is the code I use to connect
$app = new \Slim\App([
‘settings’ => [
‘displayErrorDetails’ => true,
‘db’ => [
‘driver’ => ‘mysql’,
‘host’ => ‘’,
‘port’ => ‘3306’,
‘database’ => ‘appliva’,
‘username’ => ‘root’,
‘password’ => ‘*******’,
‘charset’ => ‘utf8’,
‘collation’ => ‘utf8_unicode_ci’,
‘prefix’ => ‘’,


There could be a number of reasons why you might see that error. The username, password, host IP, or port number could be wrong. There could be a firewall or other routing issue blocking traffic. The database server might be setup to only accept local connections… Tough to guess without knowing more information about the environment and how it was setup.