Error 4033 , Reason not-authorized

When I restart a GCP instance, I get the below error:

[Connection error]


Solution 1:

According to Google Cloud FAQ:

Error Code 4033
Either you don't have permission to access the instance, the instance doesn't exist, or the instance is stopped.

Check if your firewall rules allow SSH connection, you should look for default-allow-ssh
If the firewall settings are correct, you can follow this guide: Troubleshooting SSH
I had the same problem couple of times, but they resolved themselves after couple of minutes.

Solution 2:

According to https://cloud.google.com/iap/docs/faq, Error Code 4033 means "Either you don't have permission to access the instance, the instance doesn't exist, or the instance is stopped."

Given the instance exists, following https://cloud.google.com/compute/docs/instances/connecting-advanced#cloud_iap, likely you need to grant yourself the roles/iap.tunnelResourceAccessor permission.

Personally, I found it easier to troubleshoot such issues when connecting via gcloud compute ssh ... instead of the webinterface, since gcloud seems to give better error messages currently.