Apache running but no response from server?

19,987

Solution 1

Sounds like a firewall issue if wget works from the command line.

Temporarily disable the firewall using:

service iptables stop

If it works then you know you need to add a rule to your firewall to allow port 80 and or 443.

Solution 2

On CentOS 7 or similar, check if you're running firewalld:

systemctl status firewalld

Ubuntu has ufw which is a friendlier interface to iptables. See man ufw for details.

If you see the service running, you can open port 80 by adding the http service as explained by root users:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Incidentally, I once installed CentOS 7 minimal on a machine and the firewall was not installed by default. But using another ISO on another machine, it was installed on its own. And I kept checking on the wrong one, which told me that there was no firewall!

A useful command that will tell you that it's definitely the firewall is nmap:

sudo nmap -sS -O -p80 ip-address

Starting Nmap 7.01 ( https://nmap.org ) at 2017-08-11 15:56 IST
Nmap scan report for ip-address
Host is up (0.0011s latency).
PORT   STATE SERVICE
80/tcp open  http

If you see filtered instead of open, there's no doubt a firewall. Double check you're in the right machine if you have several terminals open!

Another quick way to check from the terminal is to use curl. On the server:

curl localhost

That should return the homepage. On another machine on the network:

curl 1.2.3.4     # use the actual host's IP address

That should also return the homepage. If you have to press CTRL+C because it sits waiting, or if you get an error like Failed to connect to 1.2.3.4 port 80: No route to host but got a response when you did it locally, it's a clear sign that something, most likely a firewall, is blocking access.

Share:
19,987

Related videos on Youtube

TreyK
Author by

TreyK

Updated on September 18, 2022

Comments

  • TreyK
    TreyK almost 2 years

    I've got a fresh Fedora 15 installation on my server that's been giving me trouble.

    My first problem was that httpd wouldn't start. I kept getting an error that there was a segfault and the sysadmin eventually traced it back to a problem with mod_perl, so he removed it and httpd started fine.

    I've had another very vexing problem recently, though: I get no response from Apache.

    • I can SSH into my server
    • I've got the right IP address
    • It pings
    • The httpd service is up and running
    • I've got an index.html file in the webroot
    • If I wget XX.XXX.XXX.XXX (the server's IP address) when SSH'd into the server itself, I get a response

    But whenever I make a request to the server from any computer, regardless of ISP, I get no response - Chrome says it can't even connect. I'm absolutely stumped about how to fix it, and I've bugged the sysadmin quite a bit already. My robotics team gets this server space free from a company and I like to bug the sysadmin as little as possible about this kind of thing, but I suppose I'll have to if this question doesn't turn up any solutions.

    Thanks for any help.

    • Admin
      Admin over 12 years
      Have you checked to see if the firewall is running on the server? It is possible that it is an blocking external port 80/433 requests
  • TreyK
    TreyK over 12 years
    Awesome! Thanks, that solved it! How would I go about adding exceptions for a general purpose webserver doing FTP, HTTP, and the like?
  • enterzero
    enterzero over 12 years
    This will tell you how - cyberciti.biz/tips/…
  • digitaladdictions
    digitaladdictions over 12 years
    Depends on if you have a GUI installed or not. Being you are using Fedora rather than CentOS I figure there may be a chance you do. If you have the tool available and are running on a graphical dekstop using system-config-firewall may be easier. Do not go back and forth between command line and system-config-firewall though because one will overwrite the other.
  • ToUsIf
    ToUsIf almost 4 years
    Awesome, allowing port 80 and 443 solved the problem
  • HartleySan
    HartleySan over 2 years
    I had this issue on an AWS EC2 server I created, and the fix was to enable access for HTTP and HTTPS from the security group assigned to the EC2 instance. (I always forget to do that!)