I have a web site that runs on an Amazon EC2 Linux-based instance, and is mapped to a regular domain name (x.com). This site talks to a database on a second EC2 instance.

I need to shut down this instance and increase the computing power behind it... if I do that, how long will it take, and then when I spin the machine up again, will my site just come back online? Will the IP address, DNS info etc. all be preserved so the domain name will keep working, and it will still be able to talk to the DB?

FYI this is what I currently see for the web server in the AWS EC2 info panel (exact IP addresses changed slightly but you get the idea):

Public DNS: ec2-54-1-1-1.us-west-1.compute.amazonaws.com
Private DNS: ip-10-1-1-1.us-west-1.compute.internal
Private IPs:

Stopping and starting an EBS boot instance is very similar to simply rebooting the instance with a few exceptions, the most notable being:

  1. The instance is assigned a new internal IP address.

  2. The instance is assigned a new public IP address.

  3. If the instance is not in a VPC, then any Elastic IP address is disassociated with the instance.

  4. All data on ephemeral storage (often under /mnt) is lost

There are also some billing and availability implications which I described in this article:

Rebooting vs. Stop/Start of Amazon EC2 Instance

VPC instances have slightly different behavior including keeping Elastic IP addresses through stop/start.

If you are using an instance as a database server and you want to connect to it using the internal IP address (cheaper, faster) and you don't want to have to reconfigure the database clients after a stop/start, then you can assign an Elastic IP address to the instance and use the external Elastic IP DNS name. This will resolve to the current internal IP address after you re-associate the Elastic IP address to the restarted instance and your clients will pick up where they left off.

I go into more detail about this approach in this article:

Using Elastic IP to Identify Internal Instances on Amazon EC2

As it sounds like you've anticipated, stop/start is an easy way to change the hardware powering your instance. I wrote about this along with some instructions and warnings in this article:

Moving an EC2 Instance to a Larger (or Smaller) Instance Type

For your particular situation I would recommend assigning an Elastic IP address to the instance and changing your DNS to point to the Elastic IP address using a CNAME to the external DNS name. You could do this right after the stop/start, or you could do it ahead of time making sure everything works before the stop/start.

  • Is this still accurate? I was just on a chat with AWS support this morning and they said that the elastic IP is not disassociated when an instance is stopped. Also, I've never seen our internal IP addresses change when stopping and starting an instance.
    – bshacklett
    Feb 12 '16 at 21:03
  • @bsacklett This answer was a bit outdated. I've updated it to explain that only non-VPC instances lose the elastic IP. Today, most instances are indeed VPC. Feb 23 '16 at 17:18

So, looks like you are not using Elastic IP, as I can see from your information.

I believe you must be using CNAME in the DNS to point to this instance. If you restart you Machine then this ec2-54-1-1-1.us-west-1.compute.amazonaws.com DNS name will change and your site will stop working.

As much internal IP is concerned, it will also change, unless you are using VPC, which you are not.

So, If I were you, I will be very careful in restarting this Machine.

As much as Time is concerned, it won't take anything more than couple of minutes.

Also, if you have any iptables running at the DB instance, which is allowing just this internal IP to connect to the DB, then it also won't work, as your internal IP will change.

So, Please be careful if you want to restart this instance, and think throughly about it.


Your internal IP/hostname will change and your Elastic IP will detach (Unless you're in a VPC).

Reattach the Elastic IP after you restart the instance. I regularly do this to change instance sizes and you're only looking at a couple minutes of downtime.

Verify Apache, and any other services are set to start (chkconfig if you running amazon linux ami).


As far as I can remember, stopping the system changing its type and starting it again should not take more than 5-10 mins (it goes unsaid that its a EBS backed system). For services to start once the system is back make sure you have all the services enabled to start on reboot (like for puppet on my ubuntu 12.04 I have it enabled in /etc/default/puppet). Make a note of the IP (I did it long back so dont remember clearly) and at most your IP can get detached from the system but it would still be there in your account so go in the Elastic IP section and associate it again with the restarted system and you will be fine.


As mentioned already, if you have an elastic IP, it will re-attach to the instance, so your DNS settings shouldn't need to be touched. One way or another, however, your private IP will change. This will likely mean you'll need to update your GRANT settings in mysql. 'Cos you've not just GRANT ALL PRIVILEGES ON *.* to 'somedude'@'%' ... right? ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.