Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Invalid request since instance is not running for PostgreSQL database

We are facing an error when we try to change the PostgreSQL instance availability type from regional to zonal. 

Error: Error when reading or editing SQL User yyy@zzz.com  in instance <project id>

googleapi: Error 400: Invalid request: Invalid request since instance is not running.

An instance has been stopped by us to change the availability type.

@kumards 

0 2 266
2 REPLIES 2

The error you're encountering is due to the fact that the PostgreSQL instance needs to be stopped in order to change its availability type. When the instance is running, you cannot make this specific configuration change.

Here’s how you can resolve this:

Stop the PostgreSQL Instance:

You need to stop the instance before changing the availability type. You can do this via the Google Cloud Console, gcloud command line, or the API.

  • Using gcloud command:

     
    gcloud sql instances patch <instance-id> --activation-policy=NEVER
    
  • Or stop the instance from the Console:

    1. Go to the Google Cloud Console.
    2. Navigate to SQL -> Instances.
    3. Select the instance in question.
    4. Click on Stop.

Change the Availability Type:

Once the instance is stopped, you can proceed to change the availability type from regional to zonal.

  • Using gcloud command:

     
    gcloud sql instances patch <instance-id> --availability-type=ZONAL
    
  • Or from the Console:

    1. In the instance details page, look for Edit settings.
    2. Find the Availability Type option and switch it from Regional to Zonal.

Start the PostgreSQL Instance:

After the availability type change is complete, start the instance again.

  • Using gcloud command:

     
    gcloud sql instances patch <instance-id> --activation-policy=ALWAYS
    
  • Or from the Console:

    1. Go to the instance details page and click on Start.

This sequence ensures that the availability type change is applied correctly.

Doesn't the error clearly say the instance is not running? They also included a comment to confirm this:

An instance has been stopped by us to change the availability type.