Stay organized with collections Save and categorize content based on your preferences.
Linux Windows
This document explains how to stop or restart a Compute Engine instance. To learn more about suspending, stopping, or resetting an instance, see Suspend, stop, or reset Compute Engine instances.
Stopping an instance is useful when you no longer use it, or to modify its properties—for example, to change its machine type, or remove any attached and mounted disks. After you stop the instance, you can do the following:
Restart it to resume your workload.
Delete it if you no longer need it.
To automate stopping or restarting an instance, see the following instead:
Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudAfter installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the Go samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
JavaTo use the Java samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
Node.jsTo use the Node.js samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
PHPTo use the PHP samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
PythonTo use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
RESTTo use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
To get the permissions that you need to stop or restart a compute instance, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1
) IAM role on the project. For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to stop or restart a compute instance. To see the exact permissions that are required, expand the Required permissions section:
Required permissionsThe following permissions are required to stop or restart a compute instance:
compute.instances.stop
on the instance compute.instances.setMetadata
on the instance if it uses instance-level public SSH keys. compute.instances.start
on the instance compute.instances.startWithEncryptionKey
on the instanceYou might also be able to get these permissions with custom roles or other predefined roles.
Stop an instanceWhen you stop a compute instance, or Compute Engine does so for a scheduled action, the instance retains its attached resources, configuration settings, internal IP addresses, MAC addresses, and metadata. However, the instance loses its in-memory data and application state. If you need to retain these states, then suspend the instance instead.
Important: You keep incurring charges for any resources attached to a stopped instance. To avoid unnecessary costs, detach and delete any resources that you no longer need.You can stop an instance using the following methods, depending on whether the instance has Local SSD disks attached and how you want to handle any shutdown scripts:
Stop an instance without Local SSD disks
You can stop one or more instances simultaneously that don't have any Local SSD disks attached. Any shutdown scripts in an instance must finish running within the default shutdown period.
Stop an instance with Local SSD disks
When stopping one or more instances simultaneously that have Local SSD disks attached, you can choose to discard or preserve (Preview) the data on those disks. Any shutdown scripts in the instance must finish running within the default shutdown period.
Stop an instance from the guest OS
This approach lets you stop a single instance only after your shutdown scripts have finished running, or, if you enabled graceful shutdown, stop the instance without gracefully shutting it down, or end an ongoing graceful shutdown. Unless you manually back up data from any attached Local SSD disks to durable storage volume, stopping an instance from within its guest OS discards any data on those disks.
Depending on what you want to do when stopping an instance, use the following options:
If you've enabled graceful shutdown in the instance, then you can stop the instance without gracefully shutting it down or end an ongoing graceful shutdown using the Google Cloud console, gcloud CLI, or REST API.
To stop multiple instances simultaneously, use the Google Cloud console or, for instances located in the same zone, the gcloud CLI.
To stop one or more instances, select one of the following options:
ConsoleIn the Google Cloud console, go to the VM instances page.
Select the running instances to stop.
Click stop Stop. If there is no Stop option, click more_vert More actions > stop Stop.
In the dialog, do the following:
Optional: To stop the instances without gracefully shut them down, or end an ongoing graceful shutdown, select the Skip graceful shutdown (if applicable) checkbox.
To confirm, click Stop.
To stop one or more instances in the same zone, use the gcloud compute instances stop
command:
gcloud compute instances stop INSTANCE_NAMES \
--zone=ZONE
Replace the following:
INSTANCE_NAMES
: a list of instance names separated by spaces—for example, instance-01 instance-02 instance-03
.
ZONE
: the zone where the instances are located.
Optionally, if you've enabled graceful shutdown in one or more instances, then you can stop the instances without gracefully shutting them down, or manually end an ongoing graceful shutdown. To do so, use the gcloud beta compute instances stop
command with the --no-graceful-shutdown
flag:
Preview — The --no-graceful-shutdown
flag
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
gcloud beta compute instances stop INSTANCE_NAMES \
--no-graceful-shutdown \
--zone=ZONE
Go Java Node.js PHP Python REST
To stop an instance, make a POST
request to the instances.stop
method:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/stop
Replace the following:
INSTANCE_NAME
: the name of the instance.
PROJECT_ID
: the ID of the project where the instance is located.
ZONE
: the zone where the instance is located.
Optionally, if you've enabled graceful shutdown in an instance, you can stop the instance without gracefully shutting it down, or manually end an ongoing graceful shutdown. To do so, make a POST
request to the instances.stop
method. In the request URL, include the noGracefulShutdown=true
query parameter:
Preview — The noGracefulShutdown
query parameter
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/stop?noGracefulShutdown=true
Stop an instance with Local SSD disks
Depending on what you want to do when stopping a compute instance, use the following options:
If you've enabled graceful shutdown in the instance, then you can stop the instance without gracefully shutting it down or end an ongoing graceful shutdown using the Google Cloud console, gcloud CLI, or REST API.
To preserve the data of the Local SSD disks attached to an instance (excluding Z3 instances), stop the instance using the gcloud CLI or REST API.
Caution: If you opt to preserve the Local SSD data, then Compute Engine stores the Local SSD data on durable storage while the instance is stopped. Thus, before stopping the instance, ensure that you have enough disk quota to store the Local SSD data.To stop multiple instances simultaneously, use the Google Cloud console or, for instances located in the same zone, the gcloud CLI.
To stop one or more instances that have Local SSD disks attached, select one of the following options:
ConsoleIn the Google Cloud console, go to the VM instances page.
Select the running instances to stop.
Click stop Stop. If there is no Stop option, click more_vert More actions > stop Stop.
In the dialog, do the following:
Optional: To stop the instances without gracefully shut them down, or end an ongoing graceful shutdown, select the Skip graceful shutdown (if applicable) checkbox.
To confirm, click Stop.
When stopping one or more instances in the same zone that have Local SSD disks attached, specify whether to discard or preserve Local SSD data as follows:
To discard Local SSD data, use the gcloud compute instances stop
command with the --discard-local-ssd=true
flag:
gcloud compute instances stop INSTANCE_NAMES \
--discard-local-ssd=true \
--zone=ZONE
To preserve Local SSD data, use the gcloud beta compute instances stop
command with the --discard-local-ssd=false
flag:
Preview — The --discard-local-ssd=false
flag
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
gcloud beta compute instances stop INSTANCE_NAMES \
--discard-local-ssd=false \
--zone=ZONE
Replace the following:
INSTANCE_NAMES
: a list of instance names separated by spaces—for example, instance-01 instance-02 instance-03
.
ZONE
: the zone where the instances are located.
Optionally, if you've enabled graceful shutdown in one or more instances, you can stop the instances without gracefully shutting them down, or end an ongoing graceful shutdown. To do so, use the gcloud beta compute instances stop
command with the --no-graceful-shutdown
flag:
Preview — The --no-graceful-shutdown
flag
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
gcloud beta compute instances stop INSTANCE_NAMES \
--discard-local-ssd=DISCARD_LOCAL_SSD \
--no-graceful-shutdown \
--zone=ZONE
Replace DISCARD_LOCAL_SSD
with true
to discard the data in the Local SSD disks, or false
to preserve the data.
When stopping an instance that has Local SSD disks attached, specify whether to discard or preserve Local SSD data as follows:
To discard Local SSD data, make a POST
request to the instances.stop
method. In the request URL, include the discardLocalSsd
query parameter set to true
:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/stop?discardLocalSsd=true
To preserve Local SSD data, make a POST
request to the beta.instances.stop
method. In the request URL, include the discardLocalSsd
query parameter set to false
:
Preview — The discardLocalSsd=false
query parameter
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/stop?discardLocalSsd=false
Replace the following:
PROJECT_ID
: the ID of the project where the instance is located.
ZONE
: the zone where the instance is located.
INSTANCE_NAME
: the name of the instance.
Optionally, if you've enabled graceful shutdown in an instance, then you can stop the instance without gracefully shutting it down, or manually end an ongoing graceful shutdown. To do so, make a POST
request to the instances.stop
method. In the request URL, include the noGracefulShutdown=true
query parameter:
Preview — The noGracefulShutdown
query parameter
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/stop?discardLocalSsd=DISCARD_LOCAL_SSD&noGracefulShutdown=true
Replace DISCARD_LOCAL_SSD
with true
to discard the data in the Local SSD disks, or false
to preserve the data.
If a compute instance has Local SSD disks attached, then shutting down the guest OS automatically discards the Local SSD data. To preserve this data, manually copy the data to a persistent storage option before stopping the instance.
To stop an instance from the guest OS, select one of the following options:
LinuxIf you haven't already, then connect to the instance.
To stop the instance, select one of the following methods:
For a clean shutdown that allows the instance to run shutdown scripts before shutting down the guest OS, run the following command:
sudo shutdown -h now
Otherwise, to force a shutdown, run the following command:
sudo poweroff
If you haven't already, then connect to the instance using one of the following methods:
To stop the instance, select one of the following methods:
To cleanly stop the instance and let the instance to run shutdown scripts before shutting down the guest OS, run the following command:
shutdown /s
To force a shutdown, run the following command:
shutdown /f
You can restart a compute instance that has been fully stopped, which is when the instance state is TERMINATED
.
If you chose to preserve the data of your Local SSD disks when stopping the instance, then you might need to remount the Local SSD disks after restarting it. For more information about how to mount Local SSD disks, see Format and mounting a Local SSD device.
To restart an instance, use one of the following methods based on whether the instance has encrypted disks attached:
If your instance doesn't have encrypted disks attached, then see Restart an instance without encrypted disks.
Otherwise, see Restart an instance with encrypted disks.
You can restart multiple compute instances simultaneously or individual instances. For multiple instances, use the Google Cloud console or, for instances located in the same zone, the gcloud CLI. For individual instances, select any of the following options:
ConsoleIn the Google Cloud console, go to the VM instances page.
Select one or more instances.
Click play_arrow Start / Resume.
To restart one or more instances in the same zone, use the gcloud compute instances start
command:
gcloud compute instances start INSTANCE_NAMES \
--zone=ZONE
Replace the following:
INSTANCE_NAMES
: a list of instance names separated by spaces—for example, instance-01 instance-02 instance-03
.
ZONE
: the zone where the instances are located.
To restart an instance, make a POST
request to the instances.start
method:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/start
Replace the following:
INSTANCE_NAME
: the name of the instance to restart.
PROJECT_ID
: the ID of the project where the instance is located.
ZONE
: the zone where the instance is located.
When you restart a stopped compute instance that has attached disks that were encrypted using customer-supplied encryption keys, you must supply the encryption key information.
You can restart multiple instances simultaneously or individual instances. For multiple instances, use the Google Cloud console or, for instances located in the same zone, the gcloud CLI. For individual instances, select any of the following options:
ConsoleIn the Google Cloud console, go to the VM instances page.
Select the instances to restart.
Click play_arrow Start / Resume.
Specify encryption keys for each of the encrypted disks that are attached to the instances, and then click Start.
To restart one or more instances that use encrypted disks in the same zone, use the gcloud compute instances start
command with the --csek-key-file
flag. If you're using an RSA-wrapped key, then use the gcloud beta compute instances start
command with the --csek-key-file
flag instead:
gcloud compute instances start INSTANCE_NAMES \
--csek-key-file=ENCRYPTION_KEY_FILE \
--zone=ZONE
Replace the following:
INSTANCE_NAMES
: a list of instance names separated by spaces—for example, instance-01 instance-02 instance-03
.
ENCRYPTION_KEY_FILE
: the relative path to the JSON file that contains the customer-supplied encryption key. You can only restart multiple instances simultaneously if the instances use the same customer-supplied encryption key.
ZONE
: the zone where the instances are located.
To restart an instance that uses encrypted disks, make a POST
request to the instances.startWithEncryptionKey
method:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/startWithEncryptionKey
{
"disks": [
{
"source": "DISK_URL",
"diskEncryptionKey": {
"ENCRYPTION_TYPE": "ENCRYPTION_KEY"
}
}
]
}
Replace the following:
PROJECT_ID
: the ID of the project where the instance is located.
ZONE
: the zone where the instance is located.
INSTANCE_NAME
: the name of the instance.
DISK_URL
: the resource URL corresponding to the full resource name of the attached disk that is encrypted with a customer-supplied encryption key.
ENCRYPTION_TYPE
: the type of disk encryption that you're using, which can be one of the following: rawKey
, kmsKeyName
, or rsaEncryptedKey
. If you use the rsaEncryptedKey
type, then make a POST
request to the beta.instances.startWithEncryptionKey
method.
ENCRYPTION_KEY
: the encryption key used to encrypt the persistent disks attached to the instance. rawKey
or rsaEncryptedKey
keys must be base64-encoded. Additionally, to prepare a rsaEncryptedKey
key, see RSA key wrapping.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-08 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-08 UTC."],[[["This guide details the process of stopping and restarting Compute Engine instances, outlining methods for both instances with and without Local SSD disks."],["Stopping an instance retains its resources and settings but clears in-memory data, and can be done via the console, gcloud CLI, guest OS, or API, with options to discard or preserve data on Local SSD disks."],["To use code samples in local development, it is necessary to install and initialize the gcloud CLI and to set up Application Default Credentials for user authentication."],["Restarting a fully stopped instance is possible through various methods, including the console, gcloud CLI, and REST API, with specific steps for instances with or without encrypted disks."],["When restarting instances with customer-supplied encryption keys, you must provide the encryption key information, and there is an option to use RSA-wrapped keys."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3