šWhy Your EC2 Public IP Changes After Reboot: The Truth About "Stop and Start"


When I first started using AWS EC2, I launched an instance, noted the public IP, and everything worked fine. But after stopping and starting the instance the next day, something strange happenedā¦
The public IP had changed.
My previous connection attempts failed, and I couldnāt reach my instance.
If youāve experienced this too ā hereās why it happens and how to fix it.
š” The Root of the Issue: Dynamic Public IPs
By default, when you launch an EC2 instance in AWS and assign it a public IP, itās not static. Itās dynamically allocated from AWS's IP pool.
When you:
Stop the instance ā AWS releases the public IP.
Start it again ā A new public IP is assigned.
So if you're relying on that IP to connect (via browser, SSH, etc.), your connection will break once it changes.
š ļø The Solution: Use an Elastic IP
An Elastic IP (EIP) is a static, public IPv4 address that you can associate with your EC2 instance. Unlike default public IPs, Elastic IPs donāt change, even if you stop and start the instance.
How to allocate and attach an Elastic IP:
Go to EC2 Dashboard > Elastic IPs.
Click Allocate Elastic IP.
After itās created, click Actions > Associate Elastic IP address.
Select your EC2 instance and private IP.
Done ā now you have a fixed IP!
ā ļø Important Notes
Elastic IPs are free only when in use ā if you allocate one and donāt attach it, AWS may charge you.
You can disassociate and reassign EIPs to other instances when needed.
ā Key Takeaways
Default public IPs are temporary ā they change when the instance is stopped and started.
Elastic IPs are static ā use them if your instance needs a fixed IP.
Always update your DNS or bookmarks if youāre using the default public IP and it changes.
šÆ Final Thoughts
As a beginner, I learned the hard way that not everything in the cloud is permanent. Even something as simple as an IP address can behave differently than expected. But once you understand how Elastic IPs work, managing your EC2 instances becomes a lot smoother.
If your instance "mysteriously" stops working ā always check if the IP changed!
Subscribe to my newsletter
Read articles from Ruchika Gurbaxani directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ruchika Gurbaxani
Ruchika Gurbaxani
AWS Cloud Enthusiast | Cybersecurity Aware Cloud-savvy and security-conscious, I'm a tech enthusiast with a strong foundation in Python, C, Networking, and Cloud Computing. Currently preparing for AWS certifications, Iāve completed the Mastercard Cybersecurity Virtual Experience and hold the ZTCA (Zscaler Zero Trust Certified Associate) certification. My projects reflect a passion for secure, scalable cloud solutionsānotably SilentWhisper, an anonymous communication app. Recognized for achievements in NASAās Scientist for a Day, Smart India Hackathon, and creative competitions like painting at Raman Science Center. I'm also active on LeetCode, HackerRank, and GitHub, where I regularly enhance my problem-solving and development skills.