How to restore etc/hosts on ubuntu 14.04?

  • Posted on February 22, 2015
  • naneriAsked by naneri

I was setting up a website on DigitalOcean and have messed up because I have modified the etc/hosts file. (That was unnecessary, because I already had setup the nameservers to point to my DO droplet).

Now I don’t know how to restore it to default. Also now when I go to the domain name it gets redirected to var/www/html folder instead of var/www/ folder and the URL is rewritten to IP address.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Could you tell us a little more about what you are trying to accomplish? The problems you are describing sound like they could be related to miss-configuring your webserver (i.e. Apache).

But to answer your question… The default /etc/hosts file will look something like this: $fqdn $hostname localhost

# 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

Where if your $fqdn would be then your $hostname would be foo Also, $hostname should match the output of the hostname command.