Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've launched my first instance, and am using it as a web server. I see that it has a public DNS (a public URL), e.g.:

I can successfully go to this server in my browser, hit it via cURL, etc.

I want to use this web server for a back-end service in an app I'm building, so I placed this URL in my app's config, and it works great.

But when I manually stop and re-start my instance, I see that the public DNS changes! I've read that this happens when you explicitly stop and re-start, but doesn't happen if you just "reboot".

I don't plan on explicitly stopping and re-starting this server ever, but my question is: will this public DNS ever change on its own for any reason? E.g. if the machine abnormally crashes, or whatever.

In other words, is it safe to ship an app that's wired to this URL?

share|improve this question

1 Answer 1

up vote 49 down vote accepted

The public DNS name always matches the public IP address.

The public IP address stays the same for an instance until it is terminated or stopped. A reboot does not change the public IP address.

If an EC2 instance is in a VPC, then it will retain the same public IP address across a stop and start.

If an EC2 instance that is not in a VPC is stopped and then started started again, it will probably receive a different public IP address.

Instances can fail. When you start a new instance to replace a failed or terminated instance, it will probably receive a different public IP address.

Because instances can fail, and because you may want to change the size of an instance (with a stop/start) it is not recommended to "ship an app that's wired to [the public IP address]" (or DNS name). Once your instance is stopped/terminated/failed another user could get that IP address assigned to their instance and all your traffic would go to them.

It is recommended to use Elastic IP Addresses to associate public services with your instance. You get to keep the Elastic IP address and you can assign it to any instance you want over time, even if it's the same instance after a stop/start.

Each Elastic IP Address comes with a public DNS name, but you would probably be better off mapping your own hostname to the Elastic IP address so that the name makes more sense to humans.

Here's a guide to Elastic IP Addresses:

Here's an article I wrote that talks about the differences between rebooting and stop/start of an instance:

Rebooting vs. Stop/Start of Amazon EC2 Instance

Here's an article I wrote that provides a reason you may want to stop/start an instance even though you don't think you will today:

Moving an EC2 Instance to a Larger Size

share|improve this answer
Thank you very much! – Aseem Kishore Nov 10 '11 at 5:29
Well per info I've rebooted my ec2 instance and just discovered that the public dns changed to a new ip. Maybe the instance crashed in between but I'm not sure about that. – Nicolas Manzini May 7 '13 at 17:49
Amazon only recommends that elastic IPs are used for load balancers. So if you have a private service on an ec2 instance you'll have to manually update the ips.… – Jesse Jul 7 at 21:06
@Jesse ELBs (Elastic Load Balancers) do not use Elastic IP addresses. In fact, ELBs change IP addresses all the time and cannot be made permanent at all. Elastic IPs are applied to EC2 instances and so are exactly what is needed for the original question. – Eric Hammond Oct 17 at 23:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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