I have this error, my database is in a service other than magento and the user used to connect to the database is admin, can you help me?

PDOException: Caught PDOException (500): SQLSTATE[HY000] [2002] Connection refused in /var/www/whitelabel/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:128
#0 /var/www/whitelabel/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(128): PDO->__construct()
#1 /var/www/whitelabel/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect()
#2 /var/www/whitelabel/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(406): Zend_Db_Adapter_Pdo_Mysql->_connect()

1 Answer 1


This could be happening for variety of reasons but you can try few things -:

  1. Check PHP-fpm processes running on the server

  2. Check with hosting company may be there is some firewall rules which is preventing connectivity between Magento and MySQL

  3. May be check overrunning cron jobs

  4. If nothing else then restarting MySQL or PHP-fpm could help

  5. Worth checking db permission for the given user

  6. MySQL logs can also give you more information than just connection refused

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.