I am doing local development and literally in mid use of my site, Chrome stopped responding to my domain (let's call it local.mydomain.com) and will only give ERR_CONNECTION_REFUSED.
It works fine in Safari, Firefox, curl, etc. (macOS 14.1)
I am using my hosts file and have a record in it (that again, works everywhere else):
127.0.0.1 localhost local.mydomain.com
Here's where it gets weird - "http://localhost" works fine, but "http://127.0.0.1" does not work, nor does "http://local.mydomain.com".
Here's what I have tried (now keep in mind that for ALL of these, it works fine in other browsers AND curl on the command line):
chrome://net-internals
, removed all related domains records and removed HSTS records. Also checked the DNS lookup there and the domains all resolve to 127.0.0.1 properly (although, using 127.0.0.1 directly DOESN'T work - has to be localhost)- Flushed OS level dns (
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
) - Completely re-installed Chrome (deleted application, removed related data in
Application Support
folder, etc). - Installed Chrome Beta and tried there.
- Tried running on various ports (80, 3000, 3001, whatever - all works in other browsers, not Chrome)
- Tried adding certs and running with https (works on other browsers, not Chrome)
- Rebooted computer
- Tried in another profile on computer
chrome://flags/
, toggled any DNS related feature - no difference.- Changed IPv6 features to any available setting
- Changed OS level DNS server to other DNS servers (ie 8.8.8.8)
- Removed all cache, cookies, storage, etc.
- Hard reload.
- Added new domains to my hosts file, ran the server with that domain. Doesn't work in Chrome, works everywhere else.
In all the above cases, it works in all other browsers and in curl, but doesn't work in Chrome. Chrome (or Chrome Beta) always IMMEDIATELY gives ERR_CONNECTION_REFUSED
.
3.5 hours I've spent on this so far.
How can localhost
work but 127.0.0.1
NOT work but only in Chrome? I've seen the other way around (where localhost doesn't work), but never the actual IP. Even Chrome is saying localhost
resolves to 127.0.0.1
, but using the IP directly doesn't work. I can't make sense of it.
Update:
I have found that if I comment out the IPv6 local host line (::1 localhost
) it fixes it, which led me to try adding the custom domain to that line as well, which did fix the problem.
I would still love to know why though - why Chrome absolutely required an IPv6 specific mapping and ignored the perfectly fine IPv4 mappings available when everything else in the OS was fine with IPv4.
Also note that an almost identical machine with the same version of macOS and Chrome DOES NOT need the IPv6 mapping.
127.0.0.1 local.mydomain.com
?