"ERR_CONNECTION_REFUSED" on localhost after (I think) upgrading Apache via homebrew

Solution 1:

Okay, I ended up running

$ sudo apachectl configtest

which returned

httpd: Syntax error on line 488 of /usr/local/etc/apache2/2.2/httpd.conf: Cannot load /usr/local/Cellar/php56/5.6.14/libexec/apache2/libphp5.so into server: dlopen(/usr/local/Cellar/php56/5.6.14/libexec/apache2/libphp5.so, 10): image not found

When I edited httpd.conf, it turned out that it was trying to load two different version of libphp5.so: a new version that had been freshly installed (I think) by Homebrew, and an old version that Homebrew had (I think) deleted once it installed the new version.

For some reason, when Apache tried to load the old version of libphp5.so and found it wasn't there, this prevented Apache running at all. As soon as I deleted the line that tried to load the missing libphp5.so and restarted Apache everything worked fine.

Solution 2:

Easier for me, listening on 8080 not 80 curl -I -L localhost helped me with the right info: Failed to connect to localhost port 80: Connection refused