Chrome Slow to Resolve /etc/hosts on macOS / OS X

5,013

Solution 1

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).

Solution 2

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/

Share:
5,013

Related videos on Youtube

mkasberg
Author by

mkasberg

Updated on September 18, 2022

Comments

  • mkasberg
    mkasberg almost 2 years

    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.
  • mkasberg
    mkasberg over 7 years
    Great suggestion! I'll give it a shot & see how it goes.
  • mooyah
    mooyah over 7 years
    You can also try to use "instruments" which gives a better visualization.
  • Donald Duck
    Donald Duck over 7 years
    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...