Can I recover the public IP address or Elastic IP address associated with an EC2 instance, and how can I avoid these being changed in the future?
Last updated: 2022-08-12
I stopped and started my Amazon Elastic Compute Cloud (Amazon EC2) instance, and then the public IP address associated with the instance changed. Or, I accidentally released the Elastic IP address associated with my instance. Are IP addresses recoverable, and how can I avoid this happening in the future?
Public IP addresses
You can't manually associate or disassociate a public IP address from your instance. An instance's public IP address changes in the following scenarios:
- Stopped or hibernated instances receive a new public IP address when started again.
- If an instance's associated Elastic IP address is disassociated from the instance, then it receives a new public IP address.
When a public IP address is no longer associated with an instance, that address is returned to the public IP pool. You can't recover the same public IP address for your stopped instance.
Elastic IP addresses
It's a best practice to use an Elastic IP address. Elastic IP addresses are allocated to your account, instead of to the instance. You can associate your Elastic IP addresses to and from instances as needed.
All instances retain their associated Elastic IP addresses when stopped. AWS continues to bill for Elastic IP addresses associated with a stopped instance.
Note: You can't convert an auto-assigned dynamic public IP address to an Elastic IP address.