1

This makes it appear that my hostname if correct:

ubuntu@webserver:~$ hostname
webserver

Below is the command I'm running and the output:

ubuntu@webserver:~$ sudo hostname webserver
sudo: unable to resolve host webserver

Here is what is in my /etc/hosts file:

127.0.0.1 localhost
webserverL

# 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

Here is what is in my /etc/hostname file:

webserver

I'm needing to get this to work properly to use Apache2.

2
  • In your /etc/hosts file, is the webserverL on a different line than localhost?
    – Ross
    Mar 25, 2014 at 13:57
  • @Achu That worked after I removed the L after webserver. Since my hostname is webserver.
    – Joe
    Mar 28, 2014 at 18:19

3 Answers 3

2

Correct your /etc/hosts like this:

127.0.0.1 localhost
127.0.1.1 webserverL

# 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
0

You don't have an address associated with your hostname, edit your /etc/hosts file as follows:

  1. Open using sudo nano /etc/hosts
  2. Change the line webserverL to 127.0.0.1 webserverL
  3. Save using Ctrl+x and press y and Enter to exit.

You will need to restart you machine to make this change take effect.

0

After trying all the above without success, the following fixed this problem for me. Replaced /etc/nsswitch.conf with new one from original install media .... somehow my file at fault had somehow been stripped down to a single line only of "hosts: files" and was only 18 bytes ... the new replacement is 19 lines and is 507 bytes.

This problem had plagued me for many months and appears to be now resolved and fixed!!

Not the answer you're looking for? Browse other questions tagged .