Stop and start Amazon EC2 instances - Amazon Elastic Compute Cloud

Stop and start Amazon EC2 instances

You can stop and start your instance if it has an Amazon EBS volume as its root device. When you stop an instance, it shuts down. When you start an instance, it is typically migrated to a new underlying host computer and assigned a new public IPv4 address.

When you stop an instance, it is not deleted. If you decide that you no longer need an instance, you can terminate it. For more information, see Terminate Amazon EC2 instances. If you want to hibernate an instance to save the contents from the instance memory (RAM), see Hibernate your Amazon EC2 instance. For distinctions between instance lifecycle actions, see Differences between instance states.

Manually stop and start your instances

You can stop and start your Amazon EBS-backed instances (instances with EBS root devices). You can't stop and start instances with instance store root device.

Warning

When you stop an instance, the data on any instance store volumes is erased. Before you stop an instance, verify that you've copied any data that you need from the instance store volumes to persistent storage, such as Amazon EBS or Amazon S3.

Console
To stop and start an Amazon EBS-backed instance
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the left navigation pane, choose Instances, and then select the instance.

  3. On the Storage tab, verify that Root device type is EBS. Otherwise, you can't stop the instance.

  4. Choose Instance state, Stop instance. If this option is disabled, either the instance is already stopped or its root device is an instance store volume.

  5. When prompted for confirmation, choose Stop. It can take a few minutes for the instance to stop.

  6. To start a stopped instance, select the instance, and choose Instance state, Start instance.

  7. It can take a few minutes for the instance to enter the running state.

  8. If you stopped an Amazon EBS-backed instance and it appears "stuck" in the stopping state, you can forcibly stop it. For more information, see Troubleshoot Amazon EC2 instance stop issues.

Command line
Prerequisites

Verify that the root device of the instance is an EBS volume. For example, run the describe-instances AWS CLI command and verify that RootDeviceType is ebs, not instance-store.

To stop and start an Amazon EBS-backed instance

Use one of the following commands:

[Linux instances] Using the OS halt command from an instance does not initiate a shutdown. If you use the halt command, the instance does not terminate; instead, it places the CPU into HLT, which suspends CPU operation. The instance remains running.

Automatically stop and start your instances

You can automate stopping and starting instances with the following services:

Instance Scheduler on AWS

You can use Instance Scheduler on AWS to automate the starting and stopping of EC2 instances. For more information, see How do I use Instance Scheduler with CloudFormation to schedule EC2 instances? Note that additional charges apply.

AWS Lambda and an Amazon EventBridge rule

You can use Lambda and an EventBridge rule to stop and start your instances on a schedule. For more information, see How do I use Lambda to stop and start Amazon EC2 instances at regular intervals?

Amazon EC2 Auto Scaling

To ensure you have the correct number of Amazon EC2 instances available to handle the load for an application, create Auto Scaling groups. Amazon EC2 Auto Scaling ensures that your application always has the right capacity to handle the traffic demand, and saves costs by launching instances only when they are needed. Note that Amazon EC2 Auto Scaling terminates, rather than stops, unneeded instances. To set up Auto Scaling groups, see Get started with Amazon EC2 Auto Scaling.

Find all running and stopped instances

You can find all of your running and stopped instances across all AWS Regions on a single page using Amazon EC2 Global View. This capability is especially useful for taking inventory and finding forgotten instances. For information about how to use Global View, see View resources across Regions using Amazon EC2 Global View.

Find the initial and most recent launch times

When you describe an instance, the launch time for the instance is its most recent launch time. After you stop and start an instance, the launch time reflects the new instance start time. To find the initial launch time for an instance, even after stopping and starting it, view the time at which the primary network interface was attached to the instance.

To find the most recent launch time using the console, select the instance and look under Instance details on the Details tab. To find the attachment time for the primary network interface, look under Network interfaces on the Networking tab.

Using the AWS CLI, run the following describe-instances command to display both the initial launch time and the most recent launch time for the specified instance.

aws ec2 describe-instances --instance-id i-09453945dcf1529e9 --query 'Reservations[*].Instances[*].{InstanceID:InstanceId,InitialLaunch:NetworkInterfaces[0].Attachment.AttachTime,LastLaunch:LaunchTime}'

The following is example output.

{ "InstanceID": "i-09453945dcf1529e9", "InitialLaunch": "2024-03-31T00:47:08+00:00", "LastLaunch": "2024-06-30T00:24:06+00:00" }