# Stop and start an instance

Stop an instance to release its vCPU and memory while keeping its disks and addresses, and start it again later, possibly on another machine.

Stop an instance when you don’t need it running. A stopped instance accrues no compute usage, and it keeps its volumes, network interface and addresses. Start it again when you need it, the same instance, possibly on a different machine.

## Before you begin [#before-you-begin]

<BeforeYouBegin>

- To stop: an instance in `RUNNING`.
- To start: an instance in `STOPPED` or `FAILED`.
- The `origin` CLI, signed in. See [CLI access](/docs/platform/access/cli).

</BeforeYouBegin>

<Callout type="note">

A stopped instance’s volumes are still billed. Terminating the instance stops billing for it and deletes the volumes its launch created, except a volume that has a snapshot: that one stays and is still billed. See [Terminate an instance](/docs/compute/instances/terminate).

</Callout>

## Stop the instance [#stop-the-instance]

1. Request the stop:

   ```sh
   origin compute stop-instance --instance-urn <instance-urn>
   ```

   The platform asks the guest operating system to shut down cleanly. A guest that hasn’t shut down after 5 minutes is powered off.

1. Run `get-instance` until `status` reads `STOPPED`:

   ```sh
   origin compute get-instance --instance-urn <instance-urn>
   ```

   The instance passes through `STOPPING` first.

You can also shut the guest down from inside, with `sudo poweroff`. The instance then goes from `RUNNING` straight to `STOPPED`.

## Start the instance [#start-the-instance]

1. Request the start:

   ```sh
   origin compute start-instance --instance-urn <instance-urn>
   ```

1. Run `get-instance` until `status` reads `RUNNING`. The instance passes through `PENDING` first.
1. Verify that the guest is up. Its `healthChecks.availability` reads `AVAILABLE` once the platform has seen its network stack answer. See [Instance health checks](/docs/compute/instances/health-checks).

Starting an instance that is already `RUNNING` reports success and changes nothing. Starting one that is still `PENDING` re-sends the start it is waiting for, without disturbing a guest that is coming up. A start is refused while the instance is `INITIALIZING`, because it starts on its own once its resources are ready, and while it is `STOPPING` or `SHUTTING_DOWN`.

## Using the API [#using-the-api]

The `startInstance` and `stopInstance` mutations take the instance URN:

```graphql
mutation {
  compute {
    stopInstance(input: { instanceUrn: "<instance-urn>" }) {
      accepted
      message
    }
  }
}
```

## If this fails [#if-this-fails]

- The start is refused with `PRODUCT_UNAVAILABLE`. The instance’s type is no longer offered. Change it to an available type, then start it. See [Change an instance’s type](/docs/compute/instances/change-type).
- The start is refused with `INSUFFICIENT_CAPACITY`. A stopped instance is placed afresh when it starts. <CapacityAdvice /> To try a larger type, change the instance’s type first. See [Change an instance’s type](/docs/compute/instances/change-type).
- The instance ends up `FAILED`. Read its `statusReason`. See [When a lifecycle operation fails](/docs/compute/instances/lifecycle#when-a-lifecycle-operation-fails).

## Related [#related]

- [`stop-instance` reference](/docs/compute/reference/cli#stop-instance)
- [`start-instance` reference](/docs/compute/reference/cli#start-instance)
- [Instance lifecycle](/docs/compute/instances/lifecycle)

