Connection Refused After Migrating Site

Getting

ExceptionConverter.php(101): An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused

Database/tables are in the right place. Changed the url/db/username/password on the project, regenerated, uploaded.

Can access database from the new user@localhost from ssh with mysql on commandline.

Firewall is allowing all MySQL connections for the purposes of troubleshooting.

Machine still rejects remote MySQL connections.

Database users have % as host.

Unsure what’s going on at this point.

You better double check your connection info in the config.*.php where “*” depends on your environment, “production” or “development”.

Checked and everything appears correct there on the server.

If you have Database_Connecting server event or Connection info of production server (JSON), double check your code or settings.

You may also enable Debug and use Database_Connecting server event to log your actual connection info and check if it is valid, e.g.

Log("Connection info", $info);
1 Like

Later on I discovered this is because I had uploaded a site generated with an IP hostname when I needed a site generated with the hostname localhost.