I used to have a bunch of domains in
peterbecom.dev for testing Nginx configurations locally. But then it became impossible to test local sites in Chrome because an
.dev is force redirected to HTTPS. No problem, so I use
.local instead. However, DNS resolution was horribly slow. For example:
▶ time curl -I http://peterbecom.local/about/minimal.css > /dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 1763 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0 curl -I http://peterbecom.local/about/minimal.css > /dev/null 0.01s user 0.01s system 0% cpu 5.585 total
5.6 seconds to open a local file in Nginx.
Here's that one weird trick to solve it: Add an entry for IPv4 AND IPv6 in
So now I have:
▶ cat /etc/hosts | grep peterbecom 127.0.0.1 peterbecom.local ::1 peterbecom.local
Ah! Much better. Thing are fast again:
▶ time curl -I http://peterbecom.local/about/minimal.css > /dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 1763 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl -I http://peterbecom.local/about/minimal.css > /dev/null 0.01s user 0.01s system 37% cpu 0.041 total
0.04 seconds instead of 5.6.
This is fantastic, thank you!
Finally! This was killing me. Thank you so much.
This was killing me too. Thank you!
Thank you very much!
This was actually incredibly helpful.
I was using Prepos to live preview my websites in localhost, actually localhost was okay with prepos it was taking forever to resolve and this fixed my problem.
Wow, thank you. This made localhost like 3 times faster for me. Awesome!
1000x faster for me, many thanks!
Would love to know if this is still true, I had this exact setup before updating to Catalina and now that I have it's frustratingly dirt slow!
Worked on Catalina. Thanks.
Thanks, this saved me hours of frustration! I'm not sure what caused this to start (I didn't have ::1 in /etc/hosts for a long time).
This is a life-saver! Thank you!
Thank you so much, I was going nuts :P
What is life?! I've been blaming 'Docker For Mac' for this speed issue like an absolute plum, although random 300% CPU usage incurs some legitimate blame too. Thanks for this bit of life-saving wisdom!
Thank you for this! Muchhhhh faster now.
thank, life saving , should be added to Docker documentation
Glad I bumped into this article. Thanks!
This is still fixing issues in 2022. Thanks! (Was linked to from StackExchange: https://superuser.com/questions/525664/local-dns-resolution-really-slow-on-mac-os-x)
::FFFF:192.168.x.y for non-localhost IPs works as well.