Skip to content

Compute / Task

Stop and start an instance

Updated · 3 min read

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

On this page6 sections

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

Stop the instance

  1. Request the stop:

    terminal
    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.

  2. Run get-instance until status reads STOPPED:

    terminal
    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

  1. Request the start:

    terminal
    origin compute start-instance --instance-urn <instance-urn>
  2. Run get-instance until status reads RUNNING. The instance passes through PENDING first.

  3. Verify that the guest is up. Its healthChecks.availability reads AVAILABLE once the platform has seen its network stack answer. See Instance 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

The startInstance and stopInstance mutations take the instance URN:

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

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.
  • The start is refused with INSUFFICIENT_CAPACITY. A stopped instance is placed afresh when it starts. INSUFFICIENT_CAPACITYNo host has room for this type right now. Retry in a few minutes; a larger type may have room. gp1.core.2 is the smallest type, so there is no smaller one to try. To try a larger type, change the instance’s type first. See Change an instance’s type.
  • The instance ends up FAILED. Read its statusReason. See When a lifecycle operation fails.