- Newest
- Most votes
- Most comments
Do you work directly with EC2 or Load Balancer? If you use public IP of EC2, and don't use ElasticIP, your IP will be different after you stop and start the instance.
Hi Nithin Check these steps to resolve issue
It sounds like you're encountering a CORS (Cross-Origin Resource Sharing) issue after restarting your EC2 instance. When you restart your instance, the public IP address might change unless you have an Elastic IP associated with it. Here are some steps to troubleshoot and resolve this issue:
-
Check EC2 Public IP: Ensure your instance's public IP hasn't changed. If it has, update your UI and configurations accordingly.
-
Verify CORS Settings: Ensure your Flask server has the correct CORS settings. Use the flask-cors library to allow requests from your UI's domain.
-
Security Group Rules: Ensure your EC2 security group allows inbound traffic on the required port (e.g., port 5000 for Flask).
-
Handle Preflight Requests: Make sure your server correctly handles OPTIONS requests for preflight checks.
-
Consider Elastic IP: Associate an Elastic IP with your EC2 instance to avoid IP changes upon restart.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 8 months ago

Hi, I am using just the EC2 instance. And I am changing the public IP address for the get and post requests. As I mentioned in my question I am getting the response on postman but only on my front end I and seeing this issue and I assure you that I am correcting the IP address in my js code.