-1

I have an EC2 instance running Ubuntu 18.04, with apache2 server. I am able to connect to it via PuTTY and via FileZilla and view the server. The server is running, there is the index.html file that's created by apache2 under /var/www, but still when I type in my public IPv4 address in the browser, I cannot connect and view the apache2 welcome page (Cannot connect to it)

What may be the cause? Is it possible that it's because I am on free tier and I am already running another EC2 instance? (Which is working fine)

*Edit: I ran the following commands and these are the outputs:

netstat -plunt | grep "443 \|80 "

(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 0
0 :::80 :::* LISTEN

curl -I http://localhost

HTTP/1.1 200 OK Date: Mon, 31 Dec 2018 16:39:42 GMT Server: Apache/2.4.29 (Ubuntu) Last-Modified: Mon, 31 Dec 2018 12:54:24 GMT ETag: "2bb4-56f5oe88329x4" Accept-Ranges: bytes Content-Length: 10918 Vary: Accept-Encoding Content-Type: text/html

0

When you want to expose a service/port on an EC2 Instance, you need to create a security group which allows connections in that port and attach it to the instance.

So for example, you can create a security group like so: enter image description here

And when you attach it to the instance, it will allow connections on port 80 from all the world (0.0.0.0/0).

Also, I'd check that the server actually listens on this port, run:

netstat -plunt | grep "443 \|80 "

And to see that the server responds:

curl -I http://localhost
  • The server responds, and I already have a running EC2 instance on the same VPC, so there is already a security group that allows traffic from all IPs (The other instance is working fine and I can get to the website it's running in the browser) – sStacker Dec 31 '18 at 16:40
  • I edited the post and added the commands output – sStacker Dec 31 '18 at 16:52
  • If you run the curl command from outside of the server, which http status code is returned? – Itai Ganot Dec 31 '18 at 17:02
  • What do you mean outside of the server? where? – sStacker Dec 31 '18 at 17:09
  • You say that you can't reach the server from the browser, so I mean, instead of trying to reach the server by browser, run the curl command, just not from the server itself. I want to see how the server responds when you try to access it from the world (0.0.0.0/0) – Itai Ganot Dec 31 '18 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.