Search code examples
amazon-web-servicesdockeramazon-ec2amazon-ecs

Cannot access ecs ec2 instance public ip


I am connecting 2 docker container one python app container and redis container with each other using ECS. When I ssh into ec2 instance and curl localhost:5000 it gives the output which means the container are running and python is connected with redis. I am trying to achieve the result with ECS Ec2

enter image description here

But when I search the public ip of ec2 it doesnot show anything. My task configuration setting:

enter image description here enter image description here

and in python container I am having this setting, pulling the image from ecr and giving the port 5000:5000 and in link giving the name of redis so the it can connect to redis container. What setting Am I missing so that I can hit the python app container without doing ssh to the ec2-instance and doing curl localhost:5000


Solution

  • If the application is accessible on localhost then possible reasons are

    • Instance security group does not allow 5000 Port, so check the security group and allow HTTP traffic on port 5000.

    • An instance might be in a private subnet, but how you do ssh from bastion or directly? if directly then the issue should be resolved by following step 1.

    Use the public IP that you used for ssh and it should work

    http://ec2Public_Ip:5000