How to fix the Apache error ah00558 : Could not reliably determine the server’s fully qualified domain name

In this article we will cover how to fix the Apache Error AH00558 : Could not reliably determine the server’s fully qualified domain name.

This typically indicates that Apache is having trouble determining the server’s fully qualified domain name (FQDN).

In this tutorial, I use the IP address of 182.168.1.81 and [domain].internal. Replace my IP address of 192.168.1.81 with the IP you use on your server. As for the usage of [domain].internal, .internal is a top-level domain I (TLD). This domain is not routable and therefore cannot be accessed by the public Internet. When you see the reference to [domain].internal you can replace the [domain] part with the domain of your liking. You can also use another private/non-routable TLD.

I am running Apache2 on Ubuntu 24.04 LTS. This server is configured as a LAMP server (Linux, Apache, MySQL, and PHP). This configuration is common for most hosting servers.

I am a PHP developer and use VirtualBox to create Ubuntu LAMP servers for development and testing.

I spend most of my Linux time on the command line.

During one such session, I ran the command sudo systemctl restart apache2. As a result, the server responded : AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message.

To alleviate the Apache error AH00558 we will follow the 9 steps listed below.

1) Backup the original apache2.conf file. It is always a good idea to make a copy of any configuration file before modifying it.

The first step is to change directories to the Apache2 directory. Run this command cd /etc/apache2/. Then run this command sudo cp apache2.conf apache2.conf-original to make a copy of the original apache2.conf file.

2) Edit the Apache Configuration File following the 3 steps below:

sudo vi /etc/apache2/apache2.conf

– set the ServerName directive by entering it into the Apache configuration file. The directive looks like this : ServerName default.internal

– Save and Close the file

3) Run the command sudo apache2ctl configtest to verify Apache is configured correctly and to verify the error message is gone.

4) Restart Apache by running: sudo systemctl restart apache2

5) Verify the change by running the command: sudo tail -f /var/log/apache2/error.log

At this point, you have corrected the error message and can stop here. If you are still experiencing issues jump down to section 9) Test the Apache configuration and follow the directions there.

I added the following steps to complete setting the ServerName directive in the default virtual host.

I also added the part on how to use the Windows/Linux/macOS hosts file so you can create a private network where your servers are on a private/non-routable IP address that utilizes a non-routable/private top-level domain (TLD). I felt this tutorial would not be complete without this information.

6) Configure the ServerName directive for the default virtual host by adding the ServerName directive to the virtual host configuration file. Follow these steps:

– Run this command: cd /etc/apache2/sites-available/

– Then run this command sudo vi 000-default.conf.

– Add the ServerName directive ServerName default.internal to the 000-default.conf file.

– Your 000-default.conf configuration file should look like this:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme,
    # hostname and port 
    # that the server uses to identify itself.
    # This is used when creating
    # redirection URLs. In the context of virtual hosts,
    # the ServerName
    # specifies what hostname must appear in the request's
    # Host: header to
    # match this virtual host. For the default
    # virtual host (this file) 
    # this value is not decisive as it is used as a
    # last resort host
    # regardless. However, you must set it for any 
    # further virtual host
    # explicitly.
    # ServerName www.example.com

    ServerAdmin webmaster@localhost
    ServerName default.internal
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug,
    # info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the
    # loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/[host].error.log
    CustomLog ${APACHE_LOG_DIR}/[host].access.log combined

    # For most configuration files from 
    # conf-available/, which are
    # enabled or disabled at a global level,
    # it is possible to  
    # include a line for only one particular virtual host.
    # For example the
    # following line enables the CGI configuration
    # for this host only
    # after it has been globally disabled
    # with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Don’t forget to replace [host] with your domain name.

There is some valuable information in this file that is worth reading.

7) Configure the Windows/Linux/macOS hosts file. In this case I will show the steps necessary to modify Windows 10.

– Right mouse click on Notepad.

– Run Notepad as administrator.

– Open the hosts file : c:/windows/system32/drivers/etc/ [set drop down to show all files]and select the hosts file.

– add 182.168.1.81 default.internal to the end of the file.

– save and close

For Linux and macOS, add the IP and domain name to the hosts file by running the command sudo vi /etc/hosts and add the line 182.168.1.81 default.internal then save and close.

8) Restart Apache by running the sudo systemctl restart apache2 command.

9) Test the Apache configuration

Run the command sudo apache2ctl configtest. If the Apache AH00558 error message persists check :

Verify /etc/apache2/apache2.conf is configured correctly.

Verify /etc/apache2/sites-available/000-default.conf is configured correctly.

Run sudo tail -f /var/log/apache2/error.log in search of any errors.

Run sudo apache2ctl configtest as many times as it is necessary to get the Apache configuration correct and to remove any error messages.

When all the errors have been addressed, launch a browser and enter the domain you are using into the browser’s URL. At this point, you should see the output from the default virtual host.

Conclusion

In this article we learned how to fix the AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message error message. We learned how to configure the /etc/apache2/apache2.conf configuration file, and the /etc/apache2/sites-available/000-default.conf configuration file. We learned how to configure the hosts files for Windows/Linux/macOS so we can use a non-routable domain name that uses the .internal top-level domain (TLD). We use this TLD in conjunction with a local network that consists of private/non-routable IP addresses.