You restart Apache, and instead of a clean start you get a line like 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. The server usually still runs, which is why people ignore it. Don't. It's Apache telling you its idea of its own name is shaky, and that can bite you later with virtual hosts, redirects and SSL.
Here's what the message really means and how to fix it properly on a VPS.
Symptom
You'll see it in one of these places:
- Output of
systemctl restart apache2orhttpd - Output of
apachectl configtestorapache2ctl -t - The top of
/var/log/apache2/error.log(Debian/Ubuntu) or/var/log/httpd/error_log(AlmaLinux/Rocky)
The full text reads AH00558: Could not reliably determine the server's fully qualified domain name, using <IP or name>. Often it's followed by Syntax OK, so it's technically a warning, not an error.
Cause
When Apache starts, it needs one global name for itself. If you haven't set a global ServerName, it tries to work one out by taking the machine's hostname and doing a lookup on it. When that lookup fails, you get AH00558 and Apache falls back to an IP address, often 127.0.1.1 on Ubuntu or Debian.
The usual reasons the lookup fails:
- The hostname isn't listed in
/etc/hosts - The hostname is a short name like
vps1with no domain part - No global
ServerNameline exists in the main Apache config - You changed the hostname recently and the old entry is still sitting in
/etc/hosts
Why you shouldn't just ignore it
On a single-site box it's harmless. On a server with several virtual hosts it can cause a few annoying things: the default vhost answering for the wrong domain, self-referential redirects (like trailing-slash redirects) pointing at an IP, and confusing output from tools like Certbot's Apache plugin that read the config.
Fix, step by step
1. Check what the server thinks its name is
hostname
hostname -f
cat /etc/hosts
If hostname -f prints an error or just the short name, the resolver can't build a fully qualified name. That's your problem.
2. Fix /etc/hosts
Add a line that maps your server's public IP to its FQDN first, then the short name. Use your own values:
203.0.113.10 server1.example.com server1
127.0.0.1 localhost
Run hostname -f again. It should now print server1.example.com.
2b. Set the hostname properly if it's wrong
hostnamectl set-hostname server1.example.com
3. Set a global ServerName
This is the fix that makes the warning go away for good, no matter what the resolver does. Where you put it depends on your distro:
| Distro | Where to add it |
|---|---|
| Ubuntu / Debian | Create /etc/apache2/conf-available/servername.conf, then a2enconf servername |
| AlmaLinux / Rocky / CentOS | Add the line to /etc/httpd/conf/httpd.conf |
| cPanel/WHM server | Don't edit httpd.conf by hand. Use WHM > Basic WebHost Manager Setup or the Include Editor so EasyApache doesn't overwrite it |
On Ubuntu or Debian:
echo "ServerName server1.example.com" | sudo tee /etc/apache2/conf-available/servername.conf
sudo a2enconf servername
sudo apachectl configtest
sudo systemctl reload apache2
On AlmaLinux or Rocky, put ServerName server1.example.com near the top of httpd.conf, outside any <VirtualHost> block, then run apachectl configtest and systemctl reload httpd.
4. Verify
sudo apachectl configtest
You want a plain Syntax OK with no AH00558 line above it.
Things that trip people up
- Using a name that doesn't resolve. The ServerName doesn't need public DNS to silence the warning, but it's much better if it matches your real hostname.
- Putting it inside a VirtualHost. A vhost-level
ServerNamedoesn't count. AH00558 is about the global one. - Duplicate ServerName lines. If you add one in two files, the later one wins and you'll chase odd behaviour. Run
grep -R "ServerName" /etc/apache2(or/etc/httpd) to check. - cPanel overwriting your edit. Rebuilds regenerate
httpd.conf. Use the supported include files instead. - Nginx users. Nginx doesn't throw this message. If you see AH00558, Apache is what's actually running.
Prevention
- Set the hostname and
/etc/hostsas part of your first-hour setup on any new VPS. - Whenever you change the hostname, update
/etc/hostsin the same sitting. - Keep a global
ServerNamein config management or your provisioning script so rebuilt servers don't regress. - Run
apachectl configtestbefore every reload. It takes a second and catches most mistakes.
Frequently Asked Questions
Is AH00558 a real error?
No, it's a warning. Apache still starts and serves your sites. But it signals a naming problem worth fixing, especially if you host multiple domains.
Can I just set ServerName to localhost?
You can, and the message will disappear. It's a fine quick fix on a test box, but on a production server a real FQDN is better since some modules and tools use that name.
I set ServerName but the warning is still there. Why?
Usually the config file isn't actually loaded. On Ubuntu, check that you ran a2enconf. On AlmaLinux, make sure the line isn't inside a block and that you reloaded the service.
Does this affect my SSL certificate?
Not directly. The certificate is matched per virtual host. But a wrong global name can make redirects and Certbot detection behave oddly, so it's worth cleaning up.
Do I need to restart Apache or is a reload enough?
A reload is enough for a new ServerName. If you changed the system hostname itself, a restart is the safer option.
