P粉2657249302023-09-01 10:18:46
Connection refused: 4003 error
This means that the instance is not listening on the port you are trying to connect to or the firewall is down. In order to fix this error, we need to ensure that the listening process on the virtual machine is running and listening on the correct port. We then verify that Google Cloud Firewall is configured correctly and turned on
You should look for default-allow-ssh to see if your firewall rules allow SSH connections. If firewall and IAP don't solve your problem.
Check if you have access rights. When you add a user and grant permissions to them (or an existing user), you need to specify the hosts or network ranges that the user is allowed to connect to. Follow the steps in this Stack Question and check if you can connect now.
For more information, follow How to Allow Remote Connections to MySQL. Attached SSH troubleshooting documentation.