Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I keep getting this warning when I (re)start Apache.

* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

... waiting apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName [ OK ]

This is the content of my etc/hosts file:

#  hpdtp-ubuntu910
#testproject.localhost  localhost.localdomain   localhost
#  hpdtp-ubuntu910   localhost   testproject.localhost   hpdtp-ubuntu910

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

This is the content of my /etc/apache2/sites-enabled/000-default file:

<VirtualHost *:80>
  ServerName testproject.localhost
  DocumentRoot "/home/morpheous/work/websites/testproject/web"
  DirectoryIndex index.php
  <Directory "/home/morpheous/work/websites/testproject/web">
    AllowOverride All
    Allow from All

  Alias /sf /lib/vendor/symfony/symfony-1.3.2/data/web/sf
  <Directory "/lib/vendor/symfony/symfony-1.3.2/data/web/sf">
    AllowOverride All
    Allow from All

When I go to http://testproject.localhost, I get a blank page.

Can anyone spot what I am doing wrong?

share|improve this question

migrated from superuser.com Jan 16 '10 at 20:55

This question came from our site for computer enthusiasts and power users.

11 Answers 11

By default Ubuntu doesn't specify a ServerName in the Apache configuration, because it doesn't know what the name of your server is. It tries a reverse lookup on your IP address, which returns nothing, so it just has to use the IP address as the ServerName.

To fix it, either add a ServerName directive outside of any virtual host - e.g. in /etc/apache2/httpd.conf, or set up a reverse DNS response for your primary IP address - in this case,

It's perfectly fine to ignore it also.

share|improve this answer
This is counter-intuitive. If I add the ServerName outside of any virtual hosts - how can I serve multiple virtual hosts from the same Apache server? (this afterall, is the point of named virtual servers) - UNLESS, you are saying that I can have more than 1 ServerName entry in (say) /etc/apache2/httpd.conf –  user35402 Jul 17 '10 at 16:52
You can then add ServerName/ServerAlias inside VirtualHost blocks to make that VirtualHost only match the host names you want. Read httpd.apache.org/docs/2.2/mod/core.html#servername for the low-down. –  crb Jul 17 '10 at 22:37
I've been searching for this answer for over an hour. So much crap on the internet concerning this, but this fixed my problem. Thx –  Mike Mar 22 '13 at 5:32
@Mike you and others are genius! I've searching for this answer for four days. (Ok, not fully working days.). +1 because this is the first answer that explains that I can add a ServerName directive outside virtual hosts without affecting them. With that in mind, ReinoutS' solution worked for me (+1 to him, too). –  Sony Santos Aug 8 '13 at 3:46

Here's a quick fix:

echo ServerName $HOSTNAME > /etc/apache2/conf.d/fqdn
share|improve this answer
Thanks. None of the fixes using /etc/hosts nor httpd.conf worked for me, but this did. –  Ryan Jan 21 '13 at 18:53
Perfect, thanks! –  Jimbo Mar 6 '13 at 13:38
Fixed it on Ubuntu 13.04 running apache2, thank you! –  dmanexe May 16 '13 at 2:12
Worked fine on current Debian Wheezy :) thanks –  DominikAngerer Apr 4 at 14:51

Another way around that warning is to put a fully qualified domain name on the line of /etc/hosts. It doesn't even have to be a fqdn that would actually resolve to anything on a dns server.  hpdtp-ubuntu910.lan  hpdtp-ubuntu910

would do the trick, while also preserving the behavior of any programs that aren't expecting the extra .lan. The order is important; names with more levels should be specified first, as in this example where the .lan address comes before the other address.

share|improve this answer



Debian Linux Sid:
VirtualHost Development: have 10 server names [10 virtualhost entries inside sites-available]

Added each one a unique localhost ip address inside /etc/hosts joe localhost.localdomain localhost joe joomla schmoo forrest store publisher studios drupal graphics wordpress


The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

If you're going to add another virtualhost [I have quite a few for development] add an entry to another localhost ip and enable the site before restarting Apache2.2. newhost

For every entry you want to enable as a VirtualHost file:


joe joomla schoo forrest store publisher studios drupal graphics wordpress

All virtualhosts are enabled/disabled via a2ensite/a2dissite hostname

To suppress the following error:

``Restarting web server: apache2apache2: Could not reliably determine the server's fully >qualified domain name, using for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain >name, using for ServerName''

Edit httpd.conf under:

/etc/apache2/httpd.conf [empty file in Debian]


Look up is then resolved for all names you add, comment out or disable down the line.

In case you forget: The sole VirtualHost *:80 entry only needs to be within the ports.conf file.


NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443

<IfModule mod_gnutls.c>
Listen 443

Within your VirtualHost entry leave out VirtualHost *:80

Example: virtualhost joe

<VirtualHost *:80>
ServerAlias joe

share|improve this answer

Setting ServerName in httpd.conf did not work for me. I fixed it by setting ServerName in /etc/apache2/conf.d/name.

I'm running Ubuntu 12.10 Alpha3 and have ServerName defined in both spots.

Source: http://linuxconfig.net/manual-howto/error-solution-could-not-reliably-determine-the-servers-fully-qualified-domain-name.html

share|improve this answer
Cool, this worked for me also, had the same issue. –  Priyank Bolia Sep 13 '12 at 13:51

Your missing a server config level ServerName entry. You need to have a ServerName entry outside of any host, for apache to use as it's default. Putting a ServerName entry inside a VirtualHost will not fix the problem. See http://httpd.apache.org/docs/2.2/mod/core.html#servername.

share|improve this answer

To fix it, we need to edit the /etc/apache2/httpd.conf or /etc/apache2.conf and add the following line:

ServerName nameofserver

share|improve this answer
You're right! But this answer duplicates the content of crb's answer without providing any new information or insight. I'd consider deleting it or adding more detail that is different from other people's answers. –  Royce Williams Jan 8 '12 at 16:13
this got me going, thanks! –  Drewdin Apr 14 '12 at 2:45

I believe you need to add ServerName for default virtual host. Since its not there, it is taking default IP. And Its a kind of warning. Your web server will still be functional i guess.

share|improve this answer
I dont understand your comment. I already have ServerName in my file: <VirtualHost> ServerName mysite.localhost Could you please clarify you comment? –  morpheous Jan 16 '10 at 20:41
For the -default- virtualhost, not just a specific virtualhost. –  Kzqai May 11 '11 at 18:20

Is /etc/hosts still have these entries. (I skipped some answers above) localhost testproject.localhost

Both IP address is same here.

Give different IP address to testproject.localhost from loopback ip subnet.

share|improve this answer
  1. you have to add ServerName in your httpd.conf file using following steps

    sudo gedit /etc/apache2/httpd.conf

    By default httpd.conf file will be blank. Now, simply add the following line to the file.

    ServerName localhost

    Save the file and exit from gedit. Finally restart the server.

    sudo /etc/init.d/apache2 restart

2) Add Include httpd.conf at the end of apache2.conf

share|improve this answer

If an httpd.conf file doesn't already exist in your etc/apache2 directory after install, then the main apache configuration file, apache2.conf, will not have a reference to it so adding anything to a created httpd.conf will not do anything. You can simply add the line "ServerName hostname" to the apache2.conf file instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.