MacPorts – Fix Localhost Refuses to Connect After Upgrading to Sierra OS

apachemacosmacports

I have downloaded and installed apache, php, phpmyadmin, mysql via macports. Everything was working fine before upgrading to macOS Sierra.

After the upgrade whenever I try to access localhost I get the following error message: "This site can't be reached, localhost refused to connect."

This is happening although my settings in the apache http.conf file remain the same.

I am also providing the content of the hosts file

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

Any advice?

Best Answer

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.