Our developers use either Docker or VirtualBox (with Vagrant) to test their code locally (and the problem happens with both). To facilitate this, we modify /etc/hosts to point to the correct IP address. For example,

local.test.company.com 10.200.10.1

Some of our developers are on Linux and some are on macOS Sierra (10.12.3). On Mac, requests to local.test.company.com in Chrome (and other browsers) often take a long time (up to a minute or more) to resolve. (The problem doesn't happen on Ubuntu Linux.) During this time, the "loading icon" on the tab is the gray icon spinning to the left. As soon as it changes to the blue icon spinning to the right, it finishes very quickly. The slow loading time can be a real problem for our developers who often refresh the site during development.

Based on this question, it seems that Chrome is taking a full minute to resolve the site. This doesn't make sense to me - a site in /etc/hosts should resolve immediately. Some developers can reproduce this behavior very consistently. Others see it intermittently or don't see it at all, and I have not been able to figure out why.

Why do the requests to local.test.company.com take a long time to resolve in a web browser?

Or, what can I do to "debug" this problem and figure out what's taking so long?


Additional Notes

  • The behavior continues to happen with Chrome in "incognito mode" with "disable cache" turned on.
  • ping resolves local.test.company.com immediately.

I had the same issue in Chrome 64.0.3282.167 on macOS High Sierra (10.13.3) and this StackOverflow answer solved it for me:

https://stackoverflow.com/a/10200111/318359

Quote:

Put all your hosts file entries for localhost into one line like so:

127.0.0.1 localhost myproject.dev myotherproject.dev 
::1 localhost
  • 1
    Thank you, thank you! Been putting up with this for so long! There's also an interesting answer there regarding .local addresses being checked with bonjour before DNS: stackoverflow.com/a/17982964/2778502 – jeff-h Apr 10 at 2:34

Have you tried running dtruss on chrome to see what it is doing when it hangs?

https://opensourcehacker.com/2011/12/02/osx-strace-equivalent-dtruss-seeing-inside-applications-what-they-do-and-why-they-hang/

  • Great suggestion! I'll give it a shot & see how it goes. – mkasberg Mar 17 '17 at 16:28
  • You can also try to use "instruments" which gives a better visualization. – mooyah Mar 17 '17 at 19:43
  • 1
    Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material... – Donald Duck Mar 18 '17 at 9:05
up vote 0 down vote accepted

I eventually figured this out. As it turns out, Chrome is not necessarily resolving while the circle is spinning to the left. The circle on chrome spins to the left during data upload and to the right during data download.

I figured this out by debugging the PHP application that was being run in Chrome. PHP responds to a request from Chrome, the circle in Chrome continues spinning to the left until the first print statement in PHP. That is, until the server sends the first byte of data back to the client.

So, in summary, this was not a problem with DNS resolution at all. DNS was fine, our web application was simply not sending any data back as quickly as we thought it would (either due to being paused in the debugger or for other reasons).

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.