Skip to content

Add IPv6 loopback hosts entry for custom domains to fix slow .local DNS on macOS - #3912

Merged
youknowriad merged 1 commit into
trunkfrom
claude/keen-bose-855c2d
Jun 22, 2026
Merged

Add IPv6 loopback hosts entry for custom domains to fix slow .local DNS on macOS#3912
youknowriad merged 1 commit into
trunkfrom
claude/keen-bose-855c2d

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude Code investigated the reported .local slowdown, located the hosts-file logic, implemented the IPv6 entry plus the migration path for existing sites, and wrote the tests. The author reviewed the diff and reasoning.

Proposed Changes

On macOS, resolving a .local custom domain that only has an IPv4 entry in the hosts file can stall on an IPv6 (AAAA) lookup that has to time out before the IPv4 result is used — adding several seconds to every request for affected users (see #3655). This writes a matching ::1 loopback entry alongside the existing 127.0.0.1 entry for each custom domain, which is the standard remedy for this behavior.

Users with existing custom-domain sites are migrated automatically: the IPv6 entry is added the next time the site starts. Already-correct entries are left untouched, so no spurious elevated-permission prompt appears on startup.

The slowdown is environment-dependent (the linked issue tags it as affecting "Some (< 50%)" of users), but the extra entry is harmless for unaffected users and is the cure for those who hit it.

Testing Instructions

On a macOS machine that exhibits the slowdown:

  1. Create a Studio site with a custom .local domain.
  2. Measure: time curl -sI http://your-domain.local/ > /dev/null — note the time.
  3. With this change, restart the site so the hosts file is rewritten.
  4. Confirm /etc/hosts now contains both 127.0.0.1 your-domain.local and ::1 your-domain.local inside the # BEGIN/END WordPress Studio block.
  5. Re-measure with the same curl command — the time should drop substantially.
  6. Delete the site and confirm both entries are removed (no orphaned ::1 line).

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
…NS on macOS

Write a ::1 entry alongside the 127.0.0.1 entry so macOS doesn't stall on an IPv6 lookup timeout when resolving .local domains, which could add several seconds to every request. Existing sites are migrated to add the IPv6 entry the next time they start.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 5480e44 vs trunk

app-size

Metric trunk 5480e44 Diff Change
App Size (Mac) 2341.83 MB 2341.83 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 5480e44 Diff Change
load 788 ms 1088 ms +300 ms 🔴 38.1%

site-startup

Metric trunk 5480e44 Diff Change
siteCreation 6486 ms 6483 ms 3 ms ⚪ 0.0%
siteStartup 6979 ms 6983 ms +4 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@wojtekn

wojtekn commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

I couldn't notice any difference either, but the fix seems reasonable and harmless.

@youknowriad

Copy link
Copy Markdown
Contributor Author

I noticed local does the same as well.

@youknowriad
youknowriad merged commit 56761ee into trunk Jun 22, 2026
12 checks passed
@youknowriad
youknowriad deleted the claude/keen-bose-855c2d branch June 22, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants