I have a Flask app I want to run on an AWS EC2 instance.
When I do flask run --host=0.0.0.0, the output says its running on all addresses (0.0.0.0), localhost (127.0.0.1), and my AWS EC2's private IPv4 address. I need it to run on the public one so it's accessible anywhere on the internet. When I use the public address for the host argument, it says "Cannot assign requested address".
When I use the public address for the host argument, it says "Cannot assign requested address".
If your ENI (Elastic Network Interface) has an Elastic IP attached (or a dynamic Publiс IP), all packets are NAT'd between your public and private IPs. It happens outside the EC2 instance.
The EC2 instance only sees the private IPs of the ENI's attached to it.
I need it to run on the public one so it's accessible anywhere on the internet.
This way, requests made to your public IP will reach your Flask app, even if it only listens on the private IP.