The lifecycle of an Elastic Compute Service (ECS) instance starts from the time when the instance is created and ends when the instance is released. During the lifecycle, an instance transitions through different states. The resource usage, billing, and supported operations of an instance vary based on the status of the instance. This topic describes the different states of an instance and the transitions between instance states.
Instance states
Instance states are classified into console-based and API-based states based on how the states can be queried. Console-based states are instance states that can be queried in the ECS console. API-based states are instance states that can be queried by calling the DescribeInstanceStatus or DescribeInstances operation in the ECS API. An API-based state may correspond to multiple console-based states based on scenarios, such as whether a subscription instance is expired or whether a payment is overdue for an instance in your Alibaba Cloud account.
Instance states are classified into stable and transitory states based on attributes. Transitory states are the states that an instance temporarily enters before the instance enters a stable state. If an instance remains in a transitory state for an extended period of time, an exception occurs.
The following table describes the different lifecycle states of an instance.
Console-based state | API-based state | State attribute | State type | Status description |
Pending | Pending | Transitory | Basic | After an instance is created, the instance is in this state before the instance enters the Starting (Starting) state. |
Starting | Starting | Transitory | Basic | After an instance is created, started, or restarted, the instance is in this state before the instance enters the Running (Running) state. |
Running | Running | Stable | Basic | An instance is in this state when the instance is running. Important The Running state indicates that an instance is running. However, this state does not always indicate that the operating system of the instance is running. You can check the health status of the instance to determine whether the operating system of the instance is running. If the operating system of the instance is running, network services work as expected and you can connect to the instance by using various methods, such as SSH or Remote Desktop Protocol (RDP). For more information, see View the health status of ECS instances. |
Stopping | Stopping | Transitory | Basic | After you stop or hibernate an instance, the instance enters this state before the instance enters the Stopped (Stopped) state. |
Stopped | Stopped | Stable | Basic | When an instance is created but not started or after an instance is stopped or hibernated, the instance remains in this state. Note After you create an instance in the ECS console or by calling the RunInstances operation, the instance is automatically started. |
Expiring | Running | Stable | Billing | When a subscription instance is about to expire, the instance enters this state but continues to run as expected. We recommend that you renew the instance at the earliest opportunity. For more information, see Renewal overview. |
Expired | Stopped | Stable | Billing | When a subscription instance expires or when a pay-as-you-go instance is stopped due to an overdue payment, the instance enters this state and is pending release. For information about whether instance resources are retained, see the Impacts of resource expiration section of the "Subscription" topic and Pay-as-you-go. |
Locked | Stopped | Stable | O&M | When an instance is locked due to security reasons, the instance enters this state. You can go to the Penalties List page in the Security Control console to request to unlock the instance. |
To Be Released | Stopped | Stable | Billing | When you apply for a refund for an unexpired subscription instance, the instance enters this state. |
Transitions between instance states
The following figure shows the transitions between instance states.
To manage the status of instances, we recommend that you use the management tools of Alibaba Cloud, such as the ECS console and ECS API. For example, to enable economical mode when you stop a pay-as-you-go instance or to restart an instance to allow a new hostname to take effect, use the ECS console or call an API operation instead of performing operations within the instance operating system.
To manage the status of instances, you can perform the following operations:
The created instance enters the Pending (Pending) state, the Starting (Starting) state, and then the Running (Running) state. You can access the instance when the instance is in the Running (Running) state. For example, when an instance is in the Running (Running) state, you can connect to the instance to manage the operating system configurations, build websites, and use a browser to access the websites.
The instance enters the Stopping (Stopping) state and then the Stopped (Stopped) state. If the instance is a pay-as-you-go instance, you must stop the instance to perform specific operations on the instance, such as replacing the operating system, changing the private IP address, and changing the instance type.
If a pay-as-you-go instance is stopped in economical mode, the computing resources (vCPUs and memory) and static public IP address (also called system-assigned or auto-assigned public IP address) of the instance are released. You are no longer charged for the resources. Other resources of the instance, including the disks and the associated elastic IP address (EIP), are retained, and you are still charged for the resources.
The instance enters the Starting (Starting) state and then the Running (Running) state.
The instance enters the Stopping (Stopping) state, the Starting (Starting) state, and then the Running (Running) state. After you perform specific operations on the instance, such as changing the instance type, you must restart the instance for the operations to take effect.
When an instance is restarted, the instance may be moved to a new host. If you want your instance to remain on the same host, you can purchase a dedicated host and associate the instance with the host.
Only instances in the API-based Stopped state can be released. Instances in the API-based Stopped state may be in the console-based Stopped state or Expired state. Unexpired subscription instances cannot be released. If you want to release an unexpired subscription instance, apply for a refund or change the billing method of the instance to pay-as-you-go.
When an instance is released, the ID, static public IP address, system disk, and data disks for which Release Disk with Instance is enabled of the instance are also released and cannot be recovered. The data disks which Release Disk with Instance is disabled are automatically detached from the instance and retained. If the instance is associated with an EIP, the EIP is automatically disassociated from the instance and retained. Proceed with caution when you release instances. To prevent accidental release of instances, we recommend that you enable release protection for the instances.
Get the list of instances in a specific state
Get the list of instances in a specific state through the ECS console
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Click the filter button in the Status column to expand the state options. Select a state for filtering, and then view the list of instances in that state.
Get the list of instances in a specific state by calling an API operation
You can get the list of instances in a specific state by calling the DescribeInstances OpenAPI operation, by specifying the status parameter. For information about OpenAPI, see Integration overview.