Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Apache AH00558: Could not reliably determine the server's fully qualified domain name: set ServerName globally

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When Apache starts, reloads or runs a configuration test and prints AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message, no ServerName is set in the main server configuration, and the system host name does not resolve to a name that contains a dot. Apache picks a name for itself and carries on. Set ServerName once, outside any virtual host, and the message goes.

What the error means

The message text is in Apache's own source. Reading server/util.c at tag 2.4.62, the function ap_get_local_host logs, with the log code APLOGNO(00558) (shown in the log as AH00558), a format string that the file holds as three adjacent C string literals and that reads "%s: Could not reliably determine the server's fully qualified domain name, using %s. Set the 'ServerName' directive globally to suppress this message". The first %s is the program name (apache2 or httpd depending on the build) and the second is the name Apache settled on.

The Apache documentation for the ServerName directive says what happens when none is set: "the server attempts to deduce the client visible hostname by first asking the operating system for the system hostname, and if that fails, performing a reverse lookup on an IP address present on the system." It also says that failing to set a name the server can resolve to an IP address "will result in a startup warning", and that the name Apache then uses "will almost never be the hostname you actually want." The page shows the older form of the message without the AH00558 code: httpd: Could not reliably determine the server's fully qualified domain name, using rocinante.local for ServerName.

In the function ap_get_local_host in server/util.c (tag 2.4.62), the code runs in this order when no name is set:

  1. It asks the operating system for the host name.
  2. It looks that name up and does a reverse lookup of the address it gets.
  3. If the reverse lookup succeeds and the returned name contains a dot, Apache returns that name and logs nothing.
  4. Otherwise it falls back to the host name itself if that contains a dot, else to the IP address as text. If the lookup itself fails, it logs a separate warning and uses 127.0.0.1. In the fallback cases it then logs the AH00558 message.

In ap_fini_vhost_config in server/vhost.c (tag 2.4.62), the main server's name is taken from this function when the main server has no name of its own (if (!s->server_hostname)). The two causes the code allows are therefore a missing global ServerName, and a ServerName that sits in a place Apache does not read. The effect is a name that may be wrong in redirects. The documentation says ServerName is used "when creating self-referential redirection URLs when UseCanonicalName is set to On". For a name-based virtual host that has no ServerName of its own, the documentation says the server "will default to a fully qualified domain name (FQDN) derived from the system hostname" and calls that "counter-intuitive virtual host matching" and "discouraged".

Likely causes

Cause What you see How to confirm
No ServerName anywhere The message at every start, reload and configtest A recursive search of the configuration finds no ServerName line
ServerName only inside a VirtualHost The message remains although virtual hosts each have a name The only matches are inside VirtualHost blocks; the message asks for it "globally"
A file with ServerName exists but is not enabled (Debian and Ubuntu layout) The file is in conf-available and the message remains The file is not linked in conf-enabled
The host name has no domain part using 192.0.2.10 (an address) appears at the end of the message hostname --fqdn prints a short name or an address
The host was cloned or renamed and the name no longer resolves An address or a different name appears at the end of the message getent hosts for the host name fails or returns another address or name

Prove the cause before changing anything

All of these only read.

1. Does any ServerName exist, and where?

grep -Rn ServerName /etc/apache2 /etc/httpd

The grep manual documents -R ("Read all files under each directory, recursively. Follow all symbolic links, unlike -r") and -n (prefix with the line number). The two folders are the usual main configuration roots on Debian-family and Red Hat-family systems; one of them will not exist on your server and grep will say so. A good result for a fix is no match outside virtual hosts. A match inside a VirtualHost block does not satisfy the "globally" in the message.

2. What does the system say its name is?

hostname
hostname --fqdn

The hostname manual says the complete FQDN "is returned with hostname --fqdn" and refers to warnings in its section "THE FQDN". A short name or an address here goes with using followed by an address in the message. The same manual advises "avoid using hostname --fqdn, hostname --domain and dnsdomainname", so treat this output as a hint and rely on getent hosts in step 3.

3. Does the host name resolve?

getent hosts web01

The getent manual says that with the hosts database and a key, it passes the key to the C library lookup functions. Use your own host name. A good result is one line with an address and the name. No output means the name does not resolve on this server, so the system tables are the next place to look; the hosts(5) page describes the /etc/hosts format as one line per address with the canonical name followed by aliases.

4. On Debian and Ubuntu, is a file enabled?

ls -l /etc/apache2/conf-enabled /etc/apache2/conf-available

The a2enconf manual says it enables a file "by creating symlinks within /etc/apache2/conf-enabled" for files stored in conf-available. A file in conf-available with no link in conf-enabled is not read.

5. Run the syntax test.

apachectl configtest

The apachectl manual says configtest "parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error". On Debian-family systems the a2enconf manual lists apache2ctl(8) under See also. The AH00558 line may appear before the result; it does not mean the syntax is wrong.

Fix

The remedy the message names is one ServerName in the main server configuration, outside every VirtualHost. The documentation syntax is ServerName [scheme://]domain-name|ip-address[:port], and it recommends "an explicit hostname and port" for "optimal reliability and predictability". The context for ServerName is "server config, virtual host", so the global line belongs in the server config.

The steps below use the Debian and Ubuntu layout, a separate file enabled with a2enconf. The ServerName page gives no file locations for other layouts, so those layouts are not covered by the steps.

First save the current list of enabled configuration files:

ls -l /etc/apache2/conf-enabled > /root/conf-enabled-before.2026-12-01.txt

Check that the file name the step creates is free. A good result is No such file or directory; if the file exists, choose another name and use it in every command below:

ls -l /etc/apache2/conf-available/servername.conf

Risk: the next steps add a global server name and ask Apache to reload. A graceful reload applies the new configuration without aborting open connections, but a wrong name can change self-referential redirects and the default name for virtual hosts that lack their own ServerName.

Create the file /etc/apache2/conf-available/servername.conf with this one line, using a name that resolves to this server (here web01.example.com), then enable it and test:

ServerName web01.example.com
a2enconf servername
apachectl configtest

Run the reload only if configtest reports Syntax OK. The apachectl manual says graceful "automatically checks the configuration files as in configtest before initiating the restart":

apachectl graceful

To undo it: disable the file, test, and reload. The a2enconf manual says a2disconf disables a configuration "by removing those symlinks"; the file in conf-available stays where it is and can be removed later on its own.

a2disconf servername
apachectl configtest
apachectl graceful

Then compare ls -l /etc/apache2/conf-enabled with /root/conf-enabled-before.2026-12-01.txt; the two listings should match.

Example (illustrative): web01 (192.0.2.10) has the host name web01 with no domain, and no ServerName in /etc/apache2. apachectl configtest prints AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message followed by Syntax OK. hostname --fqdn prints web01 (a hint only, as the hostname manual advises), and getent hosts web01 prints the address 192.0.2.10 with the name web01 and no dotted name. The engineer saves the conf-enabled listing, creates servername.conf with ServerName web01.example.com, runs a2enconf servername and apachectl configtest, which now prints only Syntax OK, and then apachectl graceful.

Confirm the fix

  1. apachectl configtest prints Syntax OK and no AH00558 line.
  2. After the reload, the error log shows no new AH00558 entry. The Apache log documentation shows error log entries that carry a code such as AH00124, so look for AH00558 and check only entries dated after the reload.
  3. A request to each virtual host still answers with that host's content. The name-based virtual host documentation says matching uses the Host header, so test each name you serve.

What to watch afterwards

  • A cloned or renamed server needs the same check: the host name, getent hosts and the ServerName line should agree.
  • An explicit name does not replace a per-site ServerName in each virtual host. Keep both. For a site that serves several names, see "Browser shows the wrong certificate for a site: SNI and the default virtual host".
  • If the server runs behind a reverse proxy or load balancer, the documentation allows a scheme in ServerName (for example https://) for that case; set it to what visitors see.

Risks and limits

  • These commands have not been run or lab-tested.
  • The Apache documentation pages carry no date and describe 2.4 in general. The message text and the lookup order are a reading of the source at tag 2.4.62; a packaged build can differ in patch level.
  • The documentation says the situation produces a "startup warning". The source logs it at alert level with the startup flag. In both, the message is raised during startup and a name is chosen for Apache to use.
  • The a2enconf steps apply only to Debian and Ubuntu packaging. Red Hat-family packaging, other distributions and source builds put the main file elsewhere, and the Apache documentation gives no paths for them.
  • IPv6 addresses in ServerName are documented as unsupported and "will produce a startup error"; use a name.

Sources