skip to Main Content

I am by no means an AWS or networking/server expert, so please forgive my ignorance in the description below.

I currently have a Flask app running inside a Docker container within an EC2 instance, but cannot view it externally in a web browser when going to the EC2 instance’s public IPv4 address (either http or https versions, with and without the :8000 port indicator). When I SSH into the instance and do curl localhost:8000 it shows the whole HTML document as expected, which makes me think that it’s an EC2 issue and not a Docker issue (otherwise curl in EC2 would not show the HTML script, right?).

In the security group assigned to the instance, I have the outbound rules set to all for Type, Protocol, and Port range; with destination as 0.0.0.0/0. For inbound rules I have HTTP>TCP>80, HTTPS>TCP>443, and SSH>TCP>22, all with Source of 0.0.0.0/0.

In case it matters at all, the EC2 instance is based on an Amazon Linux 2023 AMI with ARM64 architecture (to match the docker container created on a Mac). The Docker container runs Ubuntu 22.04 and Python 3.10.12.

At this point I’m completely lost. I don’t know what I’m missing, but obviously it’s pretty crucial for being able to see the app. Any help or suggestions would be greatly appreciated.

2

Answers


  1. You need to allow port 8000 in your Security Group’s inbound rules and access the app from your local machine like this

    http://{ec2-ip}:8000
    

    Replace {ec2-ip} with the public IP of your EC2 Instance.

    Login or Signup to reply.
  2. Here are some ways to debug.

    1. Verify Firewall settings allow port 8000 outbound in Amazon Linux.

    2. Verify your ec2 is in the public subnet.

    Shortcut: If your ec2 has a public IP then it is in a public subnet.

    1. Verify port 8000 is enabled in the Security Group. Try doing it explicitly.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search