Skip to content

Getting SQLSTATE[HY000] [2002] Connection refused when running upgrade command for Magento 2.3

I am getting the following error when running the php bin/magento setup:upgrade command in my Magento 2.3 instance:

SQLSTATE[HY000] [2002] Connection refused

I can connect to the database using the mysql -u root -p and can run commands there without any issue. So I’ve determined that this is an issue with Magento’s connection to the DB. I have gone in and changed the env.php setting from localhost to 127.0.0.1 with no luck. Recently we did have a DNS change, but I’m not sure if that would effect the database. Are there any other solutions?