Ubuntu Apache Server 503 Error: disabled connection for (localhost)

503-errorapache-2.4localhostUbuntu

in a bit of a bind here. I'm trying to move a website (www.monkhouselaw.com) from one hosting company to my Digital Ocean VPS. I've changed the DNS settings to:

* -> 107.170.29.18
www -> 107.170.29.18
monkhouselaw -> 107.170.29.18

This then directs to an Apache Virtual Host on my VPS.

Currently I'm just trying to load a single PHP index page on my server. Once it works I'll bring over the WordPress install. Sadly, it's, well, not working.

Accessing www.monkhouselaw.com returns a 503 error currently. I simply can't determine why. Examining the Apache error log shows me:

(111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:3000 (localhost) failed
[Sun Jun 05 16:44:46.900331 2016] [proxy:error] [pid 2207] AH00959: ap_proxy_connect_backend disabling worker for (localhost) for 60s
[Sun Jun 05 16:44:46.900339 2016] [proxy_http:error] [pid 2207] [client 108.63.121.42:51559] AH01114: HTTP: failed to make connection to backend: localhost, referer: (long url)

And, later, this:

[Sun Jun 05 16:45:21.841236 2016] [proxy:error] [pid 2198] AH00940: HTTP: disabled connection for (localhost)

I've tried checking to see if port 3000 on localhost is listening, and it's not. However, there's a pre-existing virtual host that should be, as I understand it, redirecting requests to the 3000 port to the 80 port. The file is 000-default.conf. There's much more to the file than the following, but here's the relevant bits:

<VirtualHost *:80>
    ...

    LoadModule proxy_module {path-to-modules}/mod_proxy.so 
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

    ...       
</VirtualHost>

Though honestly, I'm unsure why it's even attempting to access port 3000, as the virtual host file for monkhouselaw is directed to the 80 port:

<VirtualHost *:80>
    DocumentRoot /var/www/monkhouse
    ServerName monkhouselaw.com
    <Directory "/var/www/monkhouse">
        allow from all
        Options None
        Require all granted
    </Directory>
</VirtualHost>

At this point I'm at a loss. Googling reveals a great many results concerning SELinux, which doesn't appear to be installed. I've seen recommendations, for example, to type the following:

togglesebool httpd_can_network_connect

Which simply returns me the message that the program 'togglesebool' does not exist.

In essence, this is a serious issue that I need to resolve, and I've been through the double-digit Google result pages trying to find solutions with no luck.

Is anyone able to offer assistance?

Best Answer

Your understanding on apache configuration is a bit backwards and upside-down. I'd suggest reading the documentation on any new software you're trying to configure. :)

In short, this part of your virtualhost config:

<VirtualHost *:80>

...has nothing to do with how apache handles connections to the virtualhost. Rather, it configures the listener which receives your request. In this case, it's listening on all IP addresses (*), on port 80 (80).

The things inside of the vhost declaration describe to apache how it is supposed to handle connections to that virtualhost. In the case of the snipped you provided, it's listening on port 80, and directing requests to port 3000, just like it's configured to do. You didn't include that entire configuration block, so it's unclear whether or not this is a name-based virtualhost.

Next, your second snippet only includes monkhouselaw.com as a ServerName. That is the only name you can use with this site and expect things to work. As you currently have things configured, www.monkhouselaw.com will not work. You need to add that as a ServerAlias.