You can call this operation to stop an ECS instance in the Running state. After the operation is called, the status of the instance changes to Stopping and then to Stopped.

Description

  • Instances whose OperationLocks array contains the "LockReason" : "security" setting cannot be stopped.
  • To stop an instance of an instance family equipped with local SSDs, take note of the following items:
    • To stop an instance of the i1 instance family equipped with local disks, call this operation with ConfirmStop set to true. Otherwise, an error code is returned.
    • Data in the local disks is cleared after the instance is stopped. We recommend that you implement data redundancy at the application layer to ensure data availability.
    • For instances of other instance families, the ConfirmStop parameter is ignored.
  • If StopCharging is selected, you can set StoppedMode to KeepCharging. Then the instance will continue to be billed after it is stopped. The instance type resources and public IP address are reserved for the instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No StopInstance

The operation that you want to perform. Set the value to StopInstance.

InstanceId String Yes i-bp67acfmxazb4ph***

The ID of the instance that you want to stop.

StoppedMode String No KeepCharging

Specifies whether billing for the instance continues after it is stopped. Valid values:

  • StopCharging: Billing stops after the instance is stopped. For conditions under which StopCharging takes effect, see the "Prerequisites" section of the "No Fees for Stopped Instances (VPC-Connected)" topic.
  • KeepCharging: Billing continues after the instance is stopped.

Default value: If the prerequisites required for enabling the No Fees for Stopped Instances (VPC-Connected) feature are met and you have enabled this feature in the ECS console (for more information, see No Fees for Stopped Instances (VPC-Connected), the default value is StopCharging. Otherwise, the default value is KeepCharging.

ConfirmStop Boolean No true

Specifies whether to confirm the stop operation. This parameter is required and takes effect only for instances of the i1 instance family.

Default value: false.

ForceStop Boolean No false

Specifies whether to forcibly stop the instance. Valid values:

  • true: forcibly stops the instance.
  • false: normally stops the instance.
DryRun Boolean No true

Specifies whether to check the request only. Default value: false. Valid values:

  • true: The request is checked and the instance is not stopped. Check items include the request format, service limits, available ECS resources, and whether the required parameters are specified. If the check fails, the corresponding error code is returned. If the check succeeds, the DryRunOperation error code is returned.
  • false: The request is checked, and the instance is stopped if the check succeeds.

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***
&ConfirmStop=true
&ForceStop=false
&StoppedMode=KeepCharging
&<Common request parameters>

Sample success responses

XML format

<StopInstanceResponse>
      <RequestId>1C488B66-B819-4D14-8711-C4EAAA13AC01</RequestId>
</StopInstanceResponse>

JSON format

{
    "RequestId": "1C488B66-B819-4D14-8711-C4EAAA13AC01"
}

Error codes

HTTP status code Error code Error message Description
404 InvalidInstanceId.NotFound The specified InstanceId does not exist. The error message returned because the specified instance ID does not exist.
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 status of the specified disk 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. If the problem persists, submit a ticket.
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 an 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 first.
403 InvalidInstanceId.NotSupport Classic network Instance does not support this operation. The error message returned because the operation is not supported by instances 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 subscription instances.
403 InvalidInstanceId.NotSupport Local disk instance does not support this operation. The error message returned because the operation is not supported by instances that use local disks.
403 InvalidInstanceId.NotSupport Spot instance does not support this operation. The error message returned because the operation is not supported by preemptible instances.
403 IncorrectInstanceStatus %s The error message returned because the operation is not supported while the instance is in the current state.
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.
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. If the problem persists, submit a ticket.

For a list of error codes, visit the API Error Center.