[SOLVED] apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName on Xubuntu

Symptom

You get this error message when starting apache:

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

Fix

Open a terminal window and run:

sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart

References

How to fix Apache – "Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName" Error on Ubuntu

Comments

  1. thanks a lot very usefull

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

    To solve this problem You need set ServerName.
    1

    $ vim /etc/apache2/conf.d/name

    For example set add ServerName localhost or any other name:
    1

    ServerName localhost

    Restart Apache 2
    1

    $ service apache restart

    ReplyDelete
  3. Doesn't work for me. And I'm even using Xubuntu (12.10) not a variant. In fact, I haven't got this little trick for the last 2 months or so, on Ubuntu, Mint or CrunchBang

    ReplyDelete
    Replies
    1. I just tried this on Xubuntu 12.10 and it worked:

      sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart

      You could try this as well.

      Delete
    2. awesome ! this works with my xubuntu THANK YOU !

      Delete
  4. "sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart"

    Tried all the trick on Linux Mint 13 64bit,none work. Please help.
    And what does the name in '/conf.d/name' mean, when I execute the command with this,I get an error that the directory doesn't exist.

    ReplyDelete
    Replies
    1. I tried on Linux Mint 14 and it worked.
      conf.d holds Apache's configuration files, there should a line inside you httpd.conf including it (Include conf.d/).

      Did you install Apache from the repositories? Please check that you typed it right.

      Delete
  5. Thanks man! Simple and Work!

    ReplyDelete
  6. Thank you, work for me in Ubuntu 12.10, i used to edit httpd.conf manually but somehow manually editing didn't work last time!!!! .. thanks again

    ReplyDelete
  7. Thanks for the suggestion. it worked. Can you also explain what was the problem and explain the command which fixes it?

    ReplyDelete
    Replies
    1. The error message says that ServerName is not set, so what the command does is to append the line "ServerName localhost" to the file /etc/apache2/conf.d/name.

      The echo command writes text to standard output. This text is appended using the bash redirection (>>).

      After the configuration is updated the Apache server is restarted using the "service" command.

      Delete
  8. thanks ! work for me in Ubuntu 12.10

    ReplyDelete
  9. Thanks a bunch. Worked for me.

    ReplyDelete
  10. You are a *. Worked like a charm

    ReplyDelete
  11. Thanks, it worked like...well it worked :)

    Mmm saturday night and I'm configuring a web server. We all have our priorities

    ReplyDelete
  12. I am using Ubuntu 12.04 and when i use the above given command the message on terminal is '* Restarting web server apache2' but when i check the browser for http://localhost:8080 i dont get the Apache server page. Please guide

    ReplyDelete
    Replies
    1. Apache uses port 80, so try http://localhost
      You can also configure Apache to make it listen to other ports.

      Delete
  13. I started getting thisk error after moving my Document Root from /var/www/ to my Dropbox folder. Here is my new entry in /etc/apache2/sites-available folder. File name is mysite:
    ------------------
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www

    Options FollowSymLinks
    AllowOverride None


    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all


    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all


    ErrorLog ${APACHE_LOG_DIR}/mysite_error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ------------------

    I have given 777 permission to the Dropbox tree ~/Dropbox/mysite/

    I put the entry ServerName localhost in a new /etc/apache2/name file and that is the only entry in that file.

    I've restarted the server countless times. I'm confused by all the misinformation on the web where Xubuntu installations of Apache2 are confused with other installations of Apache on .rpm servers. Where should I go next?

    ReplyDelete
  14. Nevermind. Saw my error in my mysite file. Corrected that and it is working find now, apparently.
    Sorry for the bother.

    ReplyDelete
  15. Worked on a Raspberry Pi "wheezy"......thank you!

    ReplyDelete
  16. I messed up with my apache2.conf,ports.conf,000-default files. And,then I reset them back (atleast that is what I thought). It led to the problem refereed in the post,which I fixed using your solution.I had edited /var/www/index.html before messing up with those files and customized it to my needs. Now ,when I type in http://localhost/ ,I get the default "It works" page. I couldn't find where this page is ,and I couldn't understand why my customized index.html is not being displayed.(although the customized index.html still lives in the /var/www/ directory ) All the other pages work fine. Any help?

    ReplyDelete
    Replies
    1. Please, open the file: /etc/apache2/sites-available/default

      Then check the value of the "DocumentRoot" directive; it should be "var/www".

      After changing the value restart apache: sudo service apache2 restart

      Delete
  17. thanks man..

    it's worked like charm :)

    ReplyDelete
  18. Hi, I've a Ubuntu 11.10 version running on my personal computer. I had entered the above mentioned command on a "Terminal" as you instructed on this site but there's no luck I'm still running the errors with the Apache2 on my computer. Kindly help me out in fixing this error ASAP.

    sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart


    Regards,
    Kelam Praveen Kumar

    ReplyDelete
    Replies
    1. Could you try the solution below?

      sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/httpd.conf' && sudo service apache2 restart

      Delete
    2. No, it didn't worked and I ended up with the new error right now.....


      Error message:

      sh: cannot create /etc/apache2/httpd.conf: Directory nonexistent

      Delete
    3. Hi, I had entered the command provided by you and after I entered the command I'm getting a new error message.

      Error message:

      * Restarting web server apache2
      Action 'start' failed.
      The Apache error log may have more information.


      I had opened the error logs but I couldn't understand as I'm a beginner and I had posted it below....



      Error.log.2.gz


      [Wed Mar 06 20:28:28 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Thu Mar 07 00:22:22 2013] [notice] caught SIGTERM, shutting down

      [Thu Mar 07 18:20:21 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Thu Mar 07 20:03:26 2013] [notice] caught SIGTERM, shutting down

      [Fri Mar 08 23:07:52 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Fri Mar 08 23:32:01 2013] [notice] caught SIGTERM, shutting down

      [Fri Mar 08 23:32:42 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Sat Mar 09 00:26:28 2013] [notice] caught SIGTERM, shutting down

      [Sun Mar 10 10:15:38 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Sun Mar 10 10:18:02 2013] [notice] SIGUSR1 received. Doing graceful restart

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



      erro.log.3.gz

      [Tue Jan 31 08:52:09 2012] [notice] Apache/2.2.17 (Ubuntu) configured -- resuming normal operations

      [Tue Jan 31 09:59:58 2012] [notice] caught SIGTERM, shutting down

      [Thu Feb 02 19:07:51 2012] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Thu Feb 02 23:07:33 2012] [notice] caught SIGTERM, shutting down

      [Fri Feb 03 12:33:14 2012] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Fri Feb 03 13:51:25 2012] [notice] caught SIGTERM, shutting down

      [Wed Mar 06 20:06:20 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Wed Mar 06 20:28:28 2013] [notice] SIGUSR1 received. Doing graceful restart

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

      Delete
  19. Hi, I've a Ubuntu 11.10 version running on my private computer. I had installed the Apache2 recently on my computer and I ended with the error while restarting the Apache2. I had entered the command provided by you on this site but nothing changed I'm still running the error while restarting the Apache2.....


    Error message:

    * Restarting web server apache2
    Action 'start' failed.
    The Apache error log may have more information..


    Kindly help me in fixing this error.....

    Thanks in advance..

    -Kelam Praveen Kumar-

    ReplyDelete
    Replies
    1. That error message isn't related with the problem exposed in this post. Please check the Apache error log for more information (/var/log/apache2/error.log)

      Delete
    2. Sorry, I had received the same error at the first place which is exposed in the post and later I ended up with the following error.

      Error message:

      * Restarting web server apache2
      Action 'start' failed.
      The Apache error log may have more information..



      As you instructed, I had checked the error log and I've entered it below....


      Error.log.2.gz



      [Wed Mar 06 20:28:28 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Thu Mar 07 00:22:22 2013] [notice] caught SIGTERM, shutting down

      [Thu Mar 07 18:20:21 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Thu Mar 07 20:03:26 2013] [notice] caught SIGTERM, shutting down

      [Fri Mar 08 23:07:52 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Fri Mar 08 23:32:01 2013] [notice] caught SIGTERM, shutting down

      [Fri Mar 08 23:32:42 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Sat Mar 09 00:26:28 2013] [notice] caught SIGTERM, shutting down

      [Sun Mar 10 10:15:38 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Sun Mar 10 10:18:02 2013] [notice] SIGUSR1 received. Doing graceful restart

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




      erro.log.3.gz


      [Tue Jan 31 08:52:09 2012] [notice] Apache/2.2.17 (Ubuntu) configured -- resuming normal operations

      [Tue Jan 31 09:59:58 2012] [notice] caught SIGTERM, shutting down

      [Thu Feb 02 19:07:51 2012] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Thu Feb 02 23:07:33 2012] [notice] caught SIGTERM, shutting down

      [Fri Feb 03 12:33:14 2012] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Fri Feb 03 13:51:25 2012] [notice] caught SIGTERM, shutting down

      [Wed Mar 06 20:06:20 2013] [notice] Apache/2.2.17 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

      [Wed Mar 06 20:28:28 2013] [notice] SIGUSR1 received. Doing graceful restart

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

      Delete
    3. It seams that Apache isn't properly installed...

      Delete
  20. Thanks a lot it works!!!

    ReplyDelete
  21. Working in Ubuntu 13.04. Thank you very much from Mexico.

    ReplyDelete
  22. Thanks.
    I think there's possibility to change localhost for real host name.

    ReplyDelete
  23. Thank you !!! From Paris :D

    ReplyDelete
  24. i have some probleme but on kali linux
    Starting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

    ReplyDelete
  25. Thanks a lot. it's working good. but i got another error. i posted in below

    please help

    $ sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart

    * Restarting web server apache2 (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    Action 'start' failed.
    The Apache error log may have more information. [fail]

    ReplyDelete
    Replies
    1. It seems that you have another service using the HTTP port (80).

      Delete

Post a Comment

Popular posts from this blog

[HOW TO] Create QR Codes in Xubuntu 12.04

[FIX] VLC is unable to open the MRL (smb://)

Add items to Xfce Applications Menu