Skip to content

Magento2 upgrading to 2.3.3 SQLSTATE[HY000] [2002] Connection refused

I’m trying to follow the devdoc instructions for a CLI upgrade from 2.3.2 to 2.3.3 but I’m getting this Connection refused error partway through the process.

My app/etc/env.php looks like this…

    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => '127.0.0.1',
                'dbname' => 'my_database_name',
                'username' => 'my_database_user',
                'password' => 'my_database_password',
                'active' => '1'
            ]
        ]
    ],

I can connect using these credentials mysql -h 127.0.0.1 -u my_database_user -p my_database_name fine.

Running a bin/magento setup:upgrade gives me….

Cache cleared successfully
File system cleanup:
/var/www/html/magento2/generated/code/Amazon
/var/www/html/magento2/generated/code/Composer
/var/www/html/magento2/generated/code/Dotdigitalgroup
/var/www/html/magento2/generated/code/Ebizmarts
/var/www/html/magento2/generated/code/Infortis
/var/www/html/magento2/generated/code/MSP
/var/www/html/magento2/generated/code/Magento
/var/www/html/magento2/generated/code/Migration
/var/www/html/magento2/generated/code/Symfony
/var/www/html/magento2/generated/code/Temando
/var/www/html/magento2/generated/code/Yotpo
The directory '/var/www/html/magento2/generated/metadata/' doesn't exist - skipping cleanup
Updating modules:
Schema creation/updates:
SQLSTATE[HY000] [2002] Connection refused

I’m really confused by this and how to correct it.

The only other clue I have is that magento.cron.log has lines of the form…

In Abstract.php line 144:

  SQLSTATE[HY000] [2002] Connection refused


In Abstract.php line 128:

  SQLSTATE[HY000] [2002] Connection refused


queue:consumers:start [--max-messages MAX-MESSAGES] [--batch-size BATCH-SIZE] [--area-code AREA-CODE] [--single-thread] [--pid-file-path PID-FILE-PATH] [--] <consumer>

Any ideas?