You run apachectl configtest, systemctl reload apache2 or systemctl status httpd, and Apache prints a line like this:
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
This is a warning, not a failure. Apache started, and your sites keep serving traffic. It appears because the main server configuration has no ServerName, so Apache tried to work out its own name from the operating system hostname and could not turn it into a proper fully qualified domain name. The address it names (127.0.1.1 on Debian and Ubuntu, sometimes 127.0.0.1 or a LAN address) is whatever your hostname resolved to.
If the server is also not working, this warning is probably a distraction. Look further up the log for an actual error, such as address already in use or a syntax problem.
Why Apache cares
Apache uses the server name to build self-referential URLs, for example when it redirects /folder to /folder/, and as the fallback when a request does not match any virtual host. With no ServerName, it does a reverse lookup of the machine's hostname, and a short name such as web01 does not qualify as an FQDN. Setting the directive removes the guesswork and the startup delay that the lookup sometimes causes on hosts with a broken resolver.
Fix: set a global ServerName
The value can be your primary hostname, or localhost if the machine has no public name. It does not have to match a real DNS record for the warning to go away, but using a name that does resolve is cleaner.
Debian and Ubuntu
Create a small config snippet and enable it:
echo "ServerName example.com" | sudo tee /etc/apache2/conf-available/servername.conf
sudo a2enconf servername
sudo apache2ctl configtest
sudo systemctl reload apache2
configtest should print Syntax OK with no AH00558 line above it.
RHEL, Rocky, AlmaLinux, Fedora
Edit /etc/httpd/conf/httpd.conf, find the commented #ServerName www.example.com:80 line and replace it:
ServerName example.com
Then check and reload:
sudo apachectl configtest && sudo systemctl reload httpd
Windows and macOS
Add the same ServerName line to httpd.conf in the Apache install directory (for XAMPP, xampp/apache/conf/httpd.conf). On a development machine, ServerName localhost is fine.
If the warning persists
- The directive is in the wrong file or is not loaded. Run
apachectl -S(orapache2ctl -S). It prints the main server name and every virtual host with the file and line where each was defined. If the main server line still says the guessed address, your snippet is not being included. - Typo or stray characters.
ServerNametakes a single hostname with an optional port. Do not puthttp://in front of it. - The hostname does not resolve. Check what the OS thinks its name is:
hostname -f
hostname -I
getent hosts "$(hostname)"
If hostname -f fails or returns only a short name, add a line to /etc/hosts such as 127.0.1.1 web01.example.com web01. Debian sets the 127.0.1.1 entry during install, which is why that address shows up in the message.
Check that nothing else is wrong
Once the warning is gone, confirm the site actually answers the way you expect. From the server and from outside:
curl -I http://localhost/
curl -I -H "Host: example.com" http://127.0.0.1/
The second request tests virtual host matching. Then use the HTTP स्टेटस चेकर from the public internet to confirm the response code, and the DNS चेकर to make sure the hostname you picked really points at this server. If you are unsure which public address the machine uses, What Is My IP opened from a browser on that server will show it.
अगले कदम
- Run a quick वेबसाइट हेल्थ चेक after reloading.
- Keep watch with an अपटाइम मॉनिटर so a bad reload pages you instead of your customers.
- If .htaccess changes cause trouble next, read Apache .htaccess 500 Internal Server Error.
- Compare behavior across servers in Apache vs nginx troubleshooting.
सामान्य प्रश्न
Is AH00558 a real error?
No. It is a warning that Apache logs at startup and reload. The server runs normally, but setting ServerName is good practice and stops the message from hiding real problems in your logs.
Does ServerName have to be a real, resolvable domain?
It does not for the warning to disappear, because any syntactically valid name works. For redirects and canonical URLs to behave well, use the actual hostname you serve, or localhost on a development box.
Why does the message say 127.0.1.1?
Debian-based systems map the machine hostname to 127.0.1.1 in /etc/hosts. Apache resolved your hostname, got that address, and reported it as the fallback.
Will this change which site Apache serves?
Not by itself. Virtual host selection is driven by each vhost's ServerName and ServerAlias matching the request's Host header. The global name only affects fallback behavior and generated URLs.
Get notified when this fix updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.