Why can't I connect to my Apache/CentOS 7 server over HTTP?
I've just installed a LAMP stack on my Linode running CentOS 7. I've already confirmed that my Linode is running and responding to pings, so what can I do to connect over http?
1 Reply
If your Linode is responding to pings but you can't connect to your website or other web services, it usually means either firewall rules are blocking connections over ports 80 and 443, or Apache is misconfigured or not working correctly so it can't accept connections on its default ports.
First, the firewall.
CentOS has firewalld enabled by default and drops connections for traffic over those ports. To enable http and https, you'll want to make sure you've added rules to allow Apache to connect using the commands below:
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
Once you add those rules, you'll want to reload firewalld to make sure they take effect with the command below. It is possible you had already added the rules for http but they hadn't actually be put in action:
firewall-cmd --reload
For more information, you can take a look at our Introduction to FirewallD on CentOS on our documentation page.
Regarding Apache
If Apache is not running or has configuration issues, it may appear as though a firewall is dropping connections. What is actually happening is Apache is not ready to accept connections when they come over those ports, so the connections are refused. The first thing you should do is make sure Apache is running and any necessary configuration you've already done take effect by forcing a reload:
sudo systemctl reload httpd
If that doesn't bring Apache up and allow you to connect over http, I would recommend taking a look at our LAMP on CentOS 7 Guide and try to work through and see if your configuration is in line with our examples. By following the guide, you should be able to bring up the default Apache page over http once it is all set up.