Apple - Localhost refuses to connect after upgrading to Sierra OS

After updating to macOS Sierra, Apache httpd moves the old httpd.conf to httpd.conf.pre-update and place the new one. In order to work the localhost work please try the below procedure:

cd /etc/apache2/  
sudo mv httpd.conf httpd.conf-afterupdate  
sudo mv httpd.conf.pre-update httpd.conf  
sudo apachectl configtest  
sudo apachectl restart  

Then test:

curl -I -L localhost

I solved this by commenting out this line from my httpd.conf:

LoadModule unique_id_module modules/mod_unique_id.so

I'm not very familiar with mod_unique_id, but it doesn't seem critical to have on my local development server (your situation might be different).

unique_id_module

This module provides a magic token for each request which is guaranteed to be unique across "all" requests under very specific conditions. The unique identifier is even unique across multiple machines in a properly configured cluster of machines. The environment variable UNIQUE_ID is set to the identifier for each request. Unique identifiers are useful for various reasons which are beyond the scope of this document.


I had the same problem. I ran sudo apachectl configtest and got the message:

AH00526: Syntax error on line 6 of /private/etc/apache2/other/default-ssl.conf:

Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration

I just renamed the default ssl config file so it's not to be loaded anymore. A apache restart later, everything came back.