MacOS – Why does Yosemite Safari never time out trying to go to *.local

macosNetworksafari

On the version of the Safari web browser that's included with Mac OS Yosemite, trying to go to any web site whose hostname ends in ".local" will cause the browser to sit there forever waiting for a response, never timing out. For example, "http://foobar.local" or "https://baz.qux.local". Same thing happens when running Safari in the iOS Simulator on a Mac (but on a real iOS device, the request properly times out).

I'm just curious – why is this? Is it likely to be a Safari bug, or a networking thing in Yosemite that I could fix by editing some config file?

I'm working on a web site that uses different URLs for media, and when running the site locally (for development) we use .local hostnames for the media sites, which used to work fine as long as /etc/hosts points these hostnames to 127.0.0.1. But now under Yosemite it's causing these requests to hang. Before I update the URLs in our code and tell all our dev to update their hosts file with new hostnames, I wanted to see if there might be a simpler fix.

Best Answer

I suppose it's because looking up a .local hostname is basically a browsing request for Bonjour services; devices & services register themselves through multicast, so since foobar.local points to no IP (unless you create it), Safari probably never reaches the stage of testing a site's reachability.

In your situation I'd rather a) setup a simple DNS server to reroute requests or b) announce your services through dns-sd:

dns-sd -P Webservice _http._tcp local 80 foobar.local 127.0.0.1 path=/webservicename

This should announce a proxy website within your network with name "Webservice" for the hostname foobar.local to be reached at http://127.0.0.1/webservicename

Related Question