Skip to main content
DevOps Insightsguides & answers

Cloud Computing · beginner

Stop, Start, Surprise: What Your EC2 Instance Forgets

Short answer

A reboot keeps everything except what is in memory. A stop and start keeps your EBS disks and private IP, but gives the instance a new public IP and erases any instance store disks (disks that belong to the physical host, not to your instance). Terminate deletes the instance and, by default, its root disk. If something points at your instance's public address, use an Elastic IP or a load balancer.

N
Neeraj Jha
4 min read
On this page · 5 sections
Diagram of What a stop and start does to one instance: 1. Stop pressed, 2. Charges pause, 3. Host released, 4. Public IP released, 5. Start pressed, 6. New public IP.

The four buttons that look alike

The EC2 console offers Reboot, Stop, Hibernate and Terminate next to each other. They read like gentler and harsher versions of the same thing. They are not. Stop and start an instance that a DNS record points at, and the record now points at an address that is no longer yours.

Think of the instance as a desk you rent. Rebooting is closing your laptop and opening it again at the same desk. Stopping is going home for the night: your locker (the EBS volume) is still yours, but tomorrow you may sit at a different desk with a different phone number. Terminating is handing back the keys.

What a stop and start does to one instance

1. Stop pressed. EC2 shuts the operating system down cleanly, or forces it after a few minutes if it will not stop.

1 / 6

The full comparison

This is the table in the EC2 User Guide, in fewer words:

RebootStop, then startHibernateTerminate
HostSameUsually newUsually newNone
Private IPv4KeptKeptKeptNone
Public IPv4KeptNewNewNone
Elastic IPStaysStaysStaysDisassociated
Instance store dataKeptErasedErasedErased
Root EBS volumeKeptKeptKeptDeleted by default
MemoryErasedErasedSaved to the root volumeErased

Stop and hibernate only work for instances whose root volume is EBS. Be careful with a shutdown from inside the operating system. On an EBS-backed instance it stops the instance by default. On an instance whose root volume is instance store, it always terminates it.

See it for yourself

Run this before and after a stop and start:

bash
aws ec2 describe-instances --instance-ids i-1234567890abcdef0 \
  --query 'Reservations[].Instances[].[State.Name,PublicIpAddress,PrivateIpAddress]' \
  --output table

The private address will match. The public one will not.

What to do about it

  • Need a stable address? Associate an Elastic IP. AWS charges for every public IPv4 address, in use or not, so release it when you are done.
  • Better still, put a load balancer in front and point DNS at that. Then no single instance's address matters.
  • Keep data you care about on EBS or S3, never on instance store disks.
  • Check the delete-on-termination setting of any volume you expect to outlive the instance.

Where to go next

The Amazon EC2 guide covers instance types, connecting without opening port 22, IMDSv2 (the safer version of the instance metadata service) and fixes for the usual SSH errors. The network around the instance, and why a subnet is public, is in the VPC guide.

Tagged with

Enjoyed this article?

Get more DevOps insights delivered to your inbox.

Get new posts by email

Subscribe to get an email when a new blog post is published. Skip anytime.

No spam, unsubscribe anytime.

N

Written by

Neeraj Jha

Platform administrator and lead writer.

View all posts →

Discussion

0 comments

Sign in to join the conversation.

Be the first to comment

Start a conversation about this post

Share: