šŸ”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:

  1. Go to EC2 Dashboard > Elastic IPs.

  2. Click Allocate Elastic IP.

  3. After it’s created, click Actions > Associate Elastic IP address.

  4. Select your EC2 instance and private IP.

  5. 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!

3
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.