> [!WARNING]
>
> **Preview**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

After you create a high availability controller, you can manually trigger a
failover. For example, you can manually trigger a failover to migrate your
workload from the primary zone to the secondary zone, test your workload's
behavior during a failover, or return your workload to the original zone after a
previous failover.

This document explains how to trigger a failover for a high availability
controller. For more information about what happens during a failover, as well
as the requirements and limitations that apply, see
[About high availability controllers](https://docs.cloud.google.com/compute/docs/instances/about-ha-controllers.md.txt).

## Before you begin

- Verify that the high availability controller and its secondary zone are ready for a failover by checking that the `status.readyForFailover` and `status.zoneStatus.SECONDARY_ZONE.isZoneReady` fields are set to `true`. To check these fields, see [View the
  details of a high availability controller](https://docs.cloud.google.com/compute/docs/instances/view-ha-controllers#view-details).
- Verify that the Compute Engine service agent, `service-PROJECT_NUMBER@compute-system.iam.gserviceaccount.com`, exists in your project and has its default permissions. Otherwise, any attempt to trigger a failover fails. For more information, see [Service agents](https://docs.cloud.google.com/iam/docs/service-agents.md.txt).
- If you haven't already, set up [authentication](https://docs.cloud.google.com/compute/docs/authentication.md.txt). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

  Select the tab for how you plan to use the samples on this page:

  ### Console


  When you use the Google Cloud console to access Google Cloud services and
  APIs, you don't need to set up authentication.

  ### gcloud

  1.
     [Install](https://docs.cloud.google.com/sdk/docs/install) the Google Cloud CLI.

     After installation,
     [initialize](https://docs.cloud.google.com/sdk/docs/initializing) the Google Cloud CLI by running the following command:

     ```bash
     gcloud init
     ```


     If you're using an external identity provider (IdP), you must first
     [sign in to the gcloud CLI with your federated identity](https://docs.cloud.google.com/iam/docs/workforce-log-in-gcloud.md.txt).

     > [!NOTE]
     > **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.

  2. [Set a default region and zone](https://docs.cloud.google.com/compute/docs/gcloud-compute.md.txt#set_default_zone_and_region_in_your_local_client).

  ### REST


  To use the REST API samples on this page in a local development environment, you use the
  credentials you provide to the gcloud CLI.
  1. [Install](https://docs.cloud.google.com/sdk/docs/install) the Google Cloud CLI.
  2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](https://docs.cloud.google.com/iam/docs/workforce-log-in-gcloud.md.txt).


  For more information, see
  [Authenticate for using REST](https://docs.cloud.google.com/docs/authentication/rest.md.txt)
  in the Google Cloud authentication documentation.

### Required roles


To get the permissions that
you need to trigger a failover for a high availability controller,

ask your administrator to grant you the
[Compute Instance Admin (v1)](https://docs.cloud.google.com/iam/docs/roles-permissions/compute.md.txt#compute.instanceAdmin.v1) (`roles/compute.instanceAdmin.v1`) IAM role on the project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


This predefined role contains

the permissions required to trigger a failover for a high availability controller. To see the exact permissions that are
required, expand the **Required permissions** section:


#### Required permissions

The following permissions are required to trigger a failover for a high availability controller:

- To trigger a failover for a high availability controller: `compute.haControllers.failover`


You might also be able to get
these permissions
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

## Trigger a failover

After you trigger a failover and the failover completes, the `state` field
returns to `ACTIVE` and the `status.primaryZone` field updates to the new
primary zone. The `status.lastFailoverInfo` field contains the timestamps and
duration of the failover. To monitor the status of the failover, see
[View the details of a high availability controller](https://docs.cloud.google.com/compute/docs/instances/view-ha-controllers.md.txt#view-details).

To trigger a failover for a high availability controller, select one of the
following options:

> [!CAUTION]
> **Caution:** During a failover, active network connections to the VM drop, and you lose any uncommitted data in the VM's memory that hasn't been written to the regional disks. Before you trigger a failover, pause your workload so that the VM writes uncommitted data from memory to the regional disks, and configure your clients to retry dropped network connections.

### Console

1. In the Google Cloud console, go to the **VM instances** page.

   [Go to VM instances](https://console.cloud.google.com/compute/instances)
2. Click the **High availability controllers** tab. A pane that shows a
   list of high availability controllers in your project appears.

3. Select the row that contains the high availability controller for which
   you want to trigger a failover. Then, click **Initiate failover**.

4. In the **Initiate failover** window that appears, enter `failover`, and
   then, to confirm, click **Failover**.

### gcloud

To trigger a failover for a high availability controller, use the
[`gcloud preview compute ha-controllers failover` command](https://docs.cloud.google.com/sdk/gcloud/reference/preview/compute/ha-controllers/failover):

    gcloud preview compute ha-controllers failover HA_CONTROLLER_NAME \
        --region=REGION \
        --failover-to-zone=SECONDARY_ZONE

Replace the following:

- `HA_CONTROLLER_NAME`: the name of the high availability
  controller.

- `REGION`: the region where the high availability
  controller exists.

- `SECONDARY_ZONE`: the secondary zone in the high
  availability controller where you want to migrate your workload.

### REST

To trigger a failover for a high availability controller, make a `POST`
request to the
[preview `haControllers.failover` method](https://docs.cloud.google.com/compute/docs/reference/rest/2026-10-01-preview/haControllers/failover.md.txt)
with the `$apiVersion=2026-10-01-preview` query parameter in the request
URL:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/haControllers/HA_CONTROLLER_NAME/failover?$apiVersion=2026-10-01-preview

    {
      "failoverToZone": "SECONDARY_ZONE"
    }

Replace the following:

- `PROJECT_ID`: the ID of your project.

- `REGION`: the region where the high availability
  controller exists.

- `HA_CONTROLLER_NAME`: the name of the high availability
  controller.

- `SECONDARY_ZONE`: the secondary zone in the high
  availability controller where you want to migrate your workload.

## What's next

- [View high availability controllers](https://docs.cloud.google.com/compute/docs/instances/view-ha-controllers.md.txt)

- [Modify a high availability controller](https://docs.cloud.google.com/compute/docs/instances/modify-ha-controller.md.txt)

- [Delete a high availability controller](https://docs.cloud.google.com/compute/docs/instances/delete-ha-controller.md.txt)

- [Troubleshoot high availability controllers](https://docs.cloud.google.com/compute/docs/troubleshooting/ha-controllers.md.txt)