Stops an Elastic Compute Service (ECS) instance in the Running state. After the operation is called, the state of the instance changes to Stopping and then to Stopped.
Description
- If you call the DescribeInstances operation to query the details of an instance and
OperationLocks
in the response contains"LockReason": "security"
, the instance is locked for security reasons and cannot be stopped. For more information, see API behavior when an instance is locked for security reasons. - If economical mode is enabled, you can set
StoppedMode
to KeepCharging to enable standard mode. Then, after your instance is stopped in standard mode, you continue to be charged for it, and its instance type resources and public IP address are retained.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | StopInstance | The operation that you want to perform. Set the value to StopInstance. |
InstanceId | String | Yes | i-bp67acfmxazb4ph**** | The ID of the instance. |
ConfirmStop | Boolean | No | true | This parameter will be removed in the future and is retained only to ensure compatibility. We recommend that you ignore this parameter. |
ForceStop | Boolean | No | false | Specifies whether to forcefully stop the instance. Valid values:
Default value: false. |
StoppedMode | String | No | KeepCharging | The stop mode of the pay-as-you-go instance. Valid values:
Default value: If the prerequisites required for enabling economical mode are met and you have enabled this mode in the ECS console, the default value is StopCharging. For more information, see the "Enable economical mode" section in |
DryRun | Boolean | No | true | Specifies whether to check the validity of the request without actually making the request. Default value: false. Valid values:
Default value: false. |
Hibernate | Boolean | No | hide | Note This parameter is currently in invitational preview and unavailable for general users. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 1C488B66-B819-4D14-8711-C4EAAA13AC01 | The ID of the request. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=StopInstance
&InstanceId=i-bp67acfmxazb4ph****
&ForceStop=false
&StoppedMode=KeepCharging
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<StopInstanceResponse>
<RequestId>1C488B66-B819-4D14-8711-C4EAAA13AC01</RequestId>
</StopInstanceResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "1C488B66-B819-4D14-8711-C4EAAA13AC01"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
403 | IncorrectInstanceStatus | The current status of the resource does not support this operation. | The error message returned because the operation is not supported while the resource is in the current state. |
403 | InstanceLockedForSecurity | The specified operation is denied as your instance is locked for security reasons. | The error message returned because the operation is not supported while the instance is locked for security reasons. |
403 | DiskError | IncorrectDiskStatus | The error message returned because the state of the specified disk is invalid. |
403 | InstanceType.ParameterMismatch | The input parameter ConfirmStop must be true when an instance have localstorage. | The error message returned because the ConfirmStop parameter is set to false for the instance that uses local storage. |
403 | InstanceExpiredOrInArrears | The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode). | The error message returned because the subscription instance has expired. Renew the instance and try later. |
403 | InvalidInstanceId.NotSupport | Classic network Instance does not support this operation. | The error message returned because the operation is not supported by the instance located in the classic network. |
403 | InvalidInstanceId.NotSupport | Pre pay instance does not support this operation. | The error message returned because the operation is not supported by the subscription instance. |
403 | InvalidInstanceId.NotSupport | Local disk instance does not support this operation. | The error message returned because the operation is not supported by the instance that uses local disks. |
403 | InvalidInstanceId.NotSupport | Spot instance does not support this operation. | The error message returned because the operation is not supported by the preemptible instance. |
403 | IncorrectInstanceStatus | %s | The error message returned because the operation is not supported while the instance is in the current state. |
403 | InvalidParameter.KMSKeyId.CMKNotEnabled | The CMK needs to be enabled. | The error message returned because the customer master key (CMK) specified by the KMSKeyId parameter is not enabled. You can call the DescribeKey operation of KMS to query information about the specified CMK. |
403 | InvalidParameter.KMSKeyId.KMSUnauthorized | ECS service have no right to access your KMS. | The error message returned because ECS is not authorized to access your KMS resources. |
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The error message returned because the specified InstanceId parameter is invalid. |
500 | InternalError | The request processing has failed due to some unknown error. | The error message returned because an internal error has occurred. Try again later. |
500 | InternalError | The request processing has failed due to some unknown error, exception or failure. | The error message returned because an internal error has occurred. Try again later. |
For a list of error codes, visit the API Error Center.