Quick summary
There is a known issue with how MacOS resolves the .local domain which can add on average around 3 - 6 seconds to the load time.
This answer on StackOverflow explains it well:
...is most likely the result of Bonjour IPv6 lookups being issued for DNS lookups on .local domains. These IPv6 lookups create a timeout delay until the original IPv4 DNS lookup is issued.
An easy fix would be to add an IPv6 entry to the etc/hosts file in addition to the IPv4 one:
127.0.0.1 my-project.local
::1 my-project.local
As far as I'm aware this is also the same thing that LocalWP does in the etc/hosts file when a new site is created.
Steps to reproduce
- Create a new site in Studio on MacOS
- Make sure to use a custom domain name (e.g.: my-project.local)
- Create a second site
- This time, make sure not to use a custom domain name
- Run the following command in a terminal to measure the time it takes to get a response from the first site:
time curl -I http://my-project.local/ > /dev/null (replace my-project.local with whatever domain name you chose at step 2)
- Run the following command in a terminal to measure the time it takes to get a response from the second site:
time curl -I http://localhost:8882/ > /dev/null (replace 8882 with the actual port of your second site)
- Compare the results
I have also tried the proposed fix by editing my etc/hosts file to add the IPv6 entry. For me, this has reduced the time for the curl command from 5.6s to 0.6s.
What you expected to happen
The DNS resolution should be fast.
What actually happened
The DNS resolution was slow.
Impact
Some (< 50%)
Available workarounds?
Yes, easy to implement
Platform
Mac Silicon
Logs or notes
No response
Quick summary
There is a known issue with how MacOS resolves the .local domain which can add on average around 3 - 6 seconds to the load time.
This answer on StackOverflow explains it well:
An easy fix would be to add an IPv6 entry to the etc/hosts file in addition to the IPv4 one:
As far as I'm aware this is also the same thing that LocalWP does in the etc/hosts file when a new site is created.
Steps to reproduce
time curl -I http://my-project.local/ > /dev/null(replace my-project.local with whatever domain name you chose at step 2)time curl -I http://localhost:8882/ > /dev/null(replace 8882 with the actual port of your second site)I have also tried the proposed fix by editing my etc/hosts file to add the IPv6 entry. For me, this has reduced the time for the curl command from 5.6s to 0.6s.
What you expected to happen
The DNS resolution should be fast.
What actually happened
The DNS resolution was slow.
Impact
Some (< 50%)
Available workarounds?
Yes, easy to implement
Platform
Mac Silicon
Logs or notes
No response