4

I am new to working with AWS so it's quite possible that I'm missing something simple, but here's the issue I'm having. I followed a tutorial to create an EC2 instance (t2.micro) and I have configured a security group to allow HTTP (port 80) from any source, but the port isn't open.

security group

I can ssh into my server with no problem, and when I use a port scanning app (e.g. http://ping.eu/port-chk/), I see that port 22 is open, but port 80 isn't. When I try wget http://localhost, I get:

Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused. 

If this helps, here are the results from sudo netstat -plunta | grep LISTEN:

tcp 0 0 0.0.0.0:55171 0.0.0.0:* LISTEN 2334/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2313/rpcbind tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2500/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2530/sendmail tcp 0 0 :::111 :::* LISTEN 2313/rpcbind tcp 0 0 :::22 :::* LISTEN 2500/sshd tcp 0 0 :::56605 :::* LISTEN 2334/rpc.statd 

EDIT:

I am using this EC2 instance to build a container from dockerhub. I am able to build the container locally with docker run -p 8000:8000 -t hsdetect, so I put it on dockerhub and tried to connect to it through port 80 using this: docker run -d -p 80:8000 jss367/hsdetect:new_port python app.py

1
  • Check your Network ACLS (NACLs) in VPC. By default they're open. Also check that you've opened incoming security group not outgoing, but it's probably not that. Could be you haven't installed a web server so nothing is listening on port 80. Basic AWS tutorial here. Commented Dec 22, 2017 at 21:36

1 Answer 1

4

Opening port 80 in your security group does not create a process in your EC2 instance listening on that port. You need to install an application, such as Apache, to listen on port 80.

Assuming that you want a web server running in your instance, install Apache.

Example commands:

sudo yum update -y sudo yum install -y httpd24 sudo service httpd start sudo chkconfig httpd on 

This will give you a simple Apache default installation.

Note: I am assuming your instance is Amazon Linux. The commands may be different for other distributions.

3
  • I have a docker build that I'm pulling from docker hub with docker run -d -p 80:8000 jss367/hsdetect:new_port python app.py. So it seems like something is wrong with the docker container (or at least the network portion of it)? Commented Dec 22, 2017 at 21:48
  • 2
    Update your question with details. Leaving out docker is a big one. The better the information that you provide the better will be the answers. Commented Dec 22, 2017 at 21:50
  • 2
    You are still leaving out lots of information. What is "jss367/hsdetect:new_port"? Something in your container if failing. Review the error messages. Update your question with enough information to help you. Commented Dec 23, 2017 at 0:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.