Apache on MacOS Sierra: AH00557: httpd: apr_sockaddr_info_get() failed for Macbook-Pro.local AH00558: httpd: Could not reliably determine…

I updated MacOS Sierra's Apache and PHP, and now whenever I $ sudo apachectl restart I get this:

AH00557: httpd: apr_sockaddr_info_get() failed for My-MacBook-Pro.local
AH00558: httpd: Could not reliably determine the server's fully qualified
domain name, using 127.0.0.1. Set the 'ServerName' directive globally to
suppress this message

Things I've tried so far that didn't work:

  • Setting ServerName localhost in /etc/httpd.conf
  • Setting ServerName localhost:80 in /etc/httpd.conf
  • Setting ServerName 127.0.0.1 in /etc/httpd.conf
  • Setting ServerName 127.0.0.1:80 in /etc/httpd.conf
  • Ensuring 127.0.0.1 localhost is set in /etc/hosts
  • Repeatedly restarting Apache

Solution 1:

When restart the httpd.

Try:

sudo /usr/sbin/apachectl restart

Don't use:

sudo apachectl restart

Solution 2:

The error message you provided gives you the answer:

Set the 'ServerName' directive globally to suppress this message

So, in your httpd.conf file, you need to set the server name by un-commenting and editing the following line

#ServerName www.example.com:80

to...

ServerName www.some-web-server.com

This should be done in the main httpd.conf and should be the FDQN (fully qualified domain name) of the server you are running. Keep in mind that this is for the main server. You can set individual server names in the VirtualHost definitions

For instance, if you called the server - mywebser.local, that should be the ServerName.

Personally, what I like to do, even in a home setup is to have a main definition that goes nowhere and is very restrictive and create virtual hosts in separate directories so each one can be referenced by a different hostname.

Solution 3:

As per message:

Set the 'ServerName' directive globally to suppress this message.

you need to find your httpd.conf Apache configuration file for example by this command:

apachectl -t -D DUMP_INCLUDES

For example: /usr/local/etc/httpd/httpd.conf.

then edit it and uncomment the line with ServerName (make sure it has the valid server name). E.g.

ServerName localhost