Skip to content

.local DNS resolution slow on MacOS #3655

@Jaessun

Description

@Jaessun

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

  1. Create a new site in Studio on MacOS
  2. Make sure to use a custom domain name (e.g.: my-project.local)
  3. Create a second site
  4. This time, make sure not to use a custom domain name
  5. 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)
  6. 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)
  7. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions