2

I have 2 instances running and a web application in one of them (Say instance1) uses private IP of another instance (Say instance2) to call a service.

I restarted instance2(IP changes after restart) and restarted the web application on instance1 after adjusting the configurations accordingly, and application was up and running successfully. But then suddenly it stopped responding after 2 hours and when I looked for the problem, I found that the private IP of the instance2 was again changed while it was running.

Has it happened with anyone else? If yes what's the solution for this?

2
  • 2
    Do you mean public IP address? Private IP addresses don't change if you stop or restart an instance. "A private IPv4 address remains associated with the network interface when the instance is stopped and restarted, and is released when the instance is terminated." https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html
    – kenlukas
    Jan 10, 2019 at 12:59
  • 1
    Also, public IP also doesn't change if the instance is simply restarted (not stopped and then started, just restarted/rebooted). Jan 10, 2019 at 14:48

2 Answers 2

9

The private IP address of an Amazon EC2 instance will never change.

It will not change while an instance is running.

It will not change while an instance is stopped.

You cannot change a private IP address. (However, I think that if you assign multiple private IP addresses, you can add/remove the secondary addresses, but not the primary IP address.)

You cannot launch another instance with the same private IP address of another instance (in the same VPC), even if the other instance is stopped.

The above only applies to the private IP address, not the public IP address.

0

In you case you need to keep your public address from changing after instance shutdown. Take a look on using ElasticIP Using ElasiticIP with EC2 instances

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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