Restarts Elastic Compute Service (ECS) instances that are in the Running state. After you call this API operation, the instances enter the Stopping state and then the Running state.
Usage notes
- The ECS instances that you want to restart must be in the Running (
Running
) state. - Batch operations are supported. You can use the
BatchOptimization
parameter to specify the batch operation mode. - Force restart (
ForceReboot
) is supported. A force restart is equivalent to powering off and restarting a traditional server. This may result in the loss of data that has not been written to the block storage in the instance operating system. - When you query the information about an ECS instance, all operations are prohibited on the instance if the response contains
{"OperationLocks": {"LockReason" : "security"}}
.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | RebootInstances | The operation that you want to perform. Set the value to RebootInstances. |
DryRun | Boolean | No | false | Specifies whether to perform only a dry run, without performing the actual request. Valid values:
Default value: false. |
RegionId | String | Yes | cn-hangzhou | The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list. |
ForceReboot | Boolean | No | false | Specifies whether to forcefully restart the instance. Valid values:
Default value: false. |
BatchOptimization | String | No | AllTogether | The batch operation mode. Valid values:
Default value: AllTogether. |
InstanceId.N | String | Yes | i-bp67acfmxazb4p**** | The ID of instance N. |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E | The ID of the request. |
InstanceResponses | Array of InstanceResponse | The instance-specific responses, which contain the status of each instance before and after the operation is called and the results of the operation. |
|
InstanceResponse | |||
Code | String | 200 | The error code returned for the instance. The return value 200 indicates that the operation was successful. For more information, see the "Error codes" section in this topic. |
Message | String | success | The error message returned for the instance. The return value Success indicates that the operation was successful. For more information, see the "Error codes" section in this topic. |
InstanceId | String | i-bp1g6zv0ce8oghu7**** | The ID of the instance. |
CurrentStatus | String | Stopping | The current status of the instance. |
PreviousStatus | String | Running | The status of the instance before the operation was called. |
Examples
Sample requests
http(s)://ecs.aliyuncs.com/?Action=RebootInstances
&InstanceId.1=i-bp1g6zv0ce8oghu7****
&InstanceId.2=i-bp1g6zv0ce8oghu7****
&InstanceId.3=i-TestID
&RegionId=cn-hangzhou
&ForceReboot=false
$BatchOptimization=SuccessFirst
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<RebootInstancesResponse>
<RequestId>FF53E96D-3F1A-42F0-8373-1C2B39D72D44</RequestId>
<InstanceResponses>
<InstanceResponse>
<Message>success</Message>
<InstanceId>i-bp1g6zv0ce8oghu7****</InstanceId>
<PreviousStatus>Running</PreviousStatus>
<CurrentStatus>Stopping</CurrentStatus>
<Code>200</Code>
</InstanceResponse>
<InstanceResponse>
<Message>success</Message>
<InstanceId>i-bp1g6zv0ce8oghu7****</InstanceId>
<PreviousStatus>Running</PreviousStatus>
<CurrentStatus>Stopping</CurrentStatus>
<Code>200</Code>
</InstanceResponse>
<InstanceResponse>
<Message>The specified InstanceId does not exist.</Message>
<InstanceId>i-TestID</InstanceId>
<PreviousStatus/>
<CurrentStatus/>
<Code>InvalidInstanceId.NotFound</Code>
</InstanceResponse>
</InstanceResponses>
</RebootInstancesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "FF53E96D-3F1A-42F0-8373-1C2B39D72D44",
"InstanceResponses" : {
"InstanceResponse" : [ {
"Message" : "success",
"InstanceId" : "i-bp1g6zv0ce8oghu7****",
"PreviousStatus" : "Running",
"CurrentStatus" : "Stopping",
"Code" : "200"
}, {
"Message" : "success",
"InstanceId" : "i-bp1g6zv0ce8oghu7****",
"PreviousStatus" : "Running",
"CurrentStatus" : "Stopping",
"Code" : "200"
}, {
"Message" : "The specified InstanceId does not exist.",
"InstanceId" : "i-TestID",
"PreviousStatus" : "",
"CurrentStatus" : "",
"Code" : "InvalidInstanceId.NotFound"
} ]
}
}
Error codes
HTTP status code | Error code | Error message | Description |
400 | InvalidParameter.KMSKeyId.CMKNotEnabled | The CMK needs to be enabled. | The customer master key (CMK) is not enabled when the ID of the CMK is specified for a disk. You can call the DescribeKey operation of KMS to query the information about the specified CMK. |
400 | DRYRUN.SUCCESS | This request is a dryrun request with successful result. | A dry run is performed and the request passes the dry run. |
403 | Abs.InvalidInstanceIds.MalFormed | The specified instanceIds is not valid. | Invalid InstanceId.N value. |
403 | IncorrectInstanceStatus | %s | The operation cannot be performed on the instance in the current state. |
403 | InvalidInstance.NotFoundSystemDisk | %s | The specified instance has no system disk and cannot be started. For more information, see the return value of the %s placeholder in the error message. Call the AttachDisk operation to attach a system disk to the specified instance. |
403 | InsufficientBalance | Your account does not have enough balance. | The account balance is insufficient. Add funds to your account and try again. |
403 | InstanceNotReady | The specified instance is not ready for use. | The operation cannot be performed on the resource in the current state. Try again later. |
404 | InvalidInstanceId.NotFound | %s | The specified instance is not found. Check whether the specified instance ID is valid. |
404 | InvalidInstanceIds.NotFound | The specified InstanceIds does not exist. | The specified instance is not found. Check whether the specified instance ID is correct. You can call the DescribeInstances operation to query the status of specific instances. |
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The instance is not found. Check whether the instance ID is correct. |
500 | InternalError | The request processing has failed due to some unknown error. | An internal error occurred. Try again later. |
For a list of error codes, see Service error codes.