I have Ubuntu 12.04, kernel 3.13. It can take 1sec to run "dig localhost" when computer is connected to Internet. When it is disconnected it is much faster. I checked /etc/hosts, I tried disabling dnsmasq in Network manager. Nothing helps. Applications that call localhost, just stop for a fraction of a second until Ubuntu goes to resolve localhost to remote servers. I search everywhere and did not find a solution. Can someone help me with this ?

; <<>> DiG 9.8.1-P1 <<>> localhost ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40343 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: ;localhost. IN A

;; ANSWER SECTION: localhost. 10800 IN A

;; Query time: 359 msec ;; SERVER: ;; WHEN: Sat Feb 7 23:02:10 2015 ;; MSG SIZE rcvd: 43

  • You say that you checked /etc/hosts, was localhost there? Also, dig uses DNS rather than the system resolver library, meaning that it will not use hosts and is not particularly suited for testing what a normal application will do. – Håkan Lindqvist Feb 7 '15 at 22:21
  • My /etc/hosts: localhost donald plus the usual IPv6 stuff. ping localhost is 0.03ms. I noticed the problem the first time when I was debugging Linphone. It takes unusually long for Linphone to register on the same machine. It takes hundreds of miliseconds, while it should be 1ms. – user269259 Feb 7 '15 at 22:32
  • ping will not actually tell you how long it took to resolve the name, though? What does for instance time getent ahosts localhost say? – Håkan Lindqvist Feb 7 '15 at 22:55
  • STREAM localhost DGRAM RAW STREAM DGRAM RAW real 0m0.002s user 0m0.000s sys 0m0.000s – user269259 Feb 7 '15 at 22:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.