Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I go to in chrome it tells me that domain can't be found. When I go to with ssh, it connects to that server. When I try to ping it pings localhost. I want to resolve to localhost in all 3 situations. How can I accomplish this?

Here are my relevant files:

/etc/hosts       localhost.localdomain   localhost
::1     laptop  localhost6.localdomain6 localhost6       laptop


# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)


# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
share|improve this question
up vote 2 down vote accepted

Unless you're actually running a DNS server such as BIND or dnsmasq on the localhost, you don't want your nameserver stanzas to point to the localhost. If you are running a DNS server or caching service, you'll need to refer to its documentation for details on how to configure it so resolves to the localhost. Once the DNS service is configured, you can test resolution of specific domain names with nslookup.

Chrome may be automatically appending 'www' to the front of your URL, you can make sure this is behavior is disabled by specifying the protocol portion of the URL explicitly, like so: ""

We'd need to see your /etc/nsswitch.conf file to help with the ssh connection. ssh -v may also produce some useful output.

Finally, if you want to connect to the localhost, it may be much less of a headache to simply specify 'localhost' as your hostname, instead of '' :)

share|improve this answer

Try to clear your DNS cache and then remove all history in Chrome (should be somewhere easy-accessible under settings, this is good to do since I'm not entirely sure if Chrome is DNS-caching)

See for clearing cache (I'm not entirely sure that is needed or is possible, but try it ;D)

Also try to dig since that could give some helpful information. You could also try by starting up Firefox and see if goes to localhost.

Also - I don't think you have to (or should, unless you've got a DNS-server set up to replicate other DNS-servers) point your nameservers to since /etc/hosts has higher priority than that of the nameservers per default (see the hosts-line in /etc/nsswitch.conf for your settings)

share|improve this answer

To address the original question.

First, why do you get three different results from Chrome, ssh and ping?

It looks to me as if these three programs use different resolver logic, perhaps using different libraries or different flanking code. It is known that ping uses the glibc resolver which obeys /etc/nsswitch.conf and /etc/resolv.conf. Hence ping first tries /etc/hosts and then DNS. So ping pings Perhaps Chrome skips /etc/hosts and can't find in DNS. As for ssh, what host does it end up connecting to?

share|improve this answer

You know if in your network has some proxy server? If has maybe is a restriction in this server. If you has control OK, but if other SysAdmin manage, you need talk with him.

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.