Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to Amazon EC2. 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.:

ec2-123-45-6-789.compute-1.amazonaws.com

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-started 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?

Thanks!

share|improve this question

1 Answer 1

up vote 42 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 a stopped instance is 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:

http://aws.amazon.com/articles/1346

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
http://alestic.com/2011/09/ec2-reboot-stop-start

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
http://alestic.com/2011/02/ec2-change-type

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

Your Answer

 
discard

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.