<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>160504</bug_id>
          
          <creation_ts>2016-08-03 06:21:29 -0700</creation_ts>
          <short_desc>Localhost subdomains don&apos;t work</short_desc>
          <delta_ts>2025-09-19 13:18:38 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>Safari 9</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=171934</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=127676</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=232223</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=236049</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dave Jeffery">djeffery</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>contact</cc>
    
    <cc>diogeneshamilton</cc>
    
    <cc>fran</cc>
    
    <cc>fred.wang</cc>
    
    <cc>ggaren</cc>
    
    <cc>github.j</cc>
    
    <cc>gulaschsuppe2</cc>
    
    <cc>ianopolous</cc>
    
    <cc>jfernandez</cc>
    
    <cc>jjprevite</cc>
    
    <cc>lidel</cc>
    
    <cc>livid</cc>
    
    <cc>marcosc</cc>
    
    <cc>me</cc>
    
    <cc>michael+webkit</cc>
    
    <cc>mikaela</cc>
    
    <cc>mrsebastienleblanc</cc>
    
    <cc>ryan</cc>
    
    <cc>sabberworm</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>yoseduj</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1216902</commentid>
    <comment_count>0</comment_count>
    <who name="Dave Jeffery">djeffery</who>
    <bug_when>2016-08-03 06:21:29 -0700</bug_when>
    <thetext>Summary:
Localhost subdomains (i.e. &apos;http://mysite.localhost&apos;) don&apos;t work in Safari. They work ok in all other web browsers (Chrome, Firefox, Opera etc..).
I am not sure if this is a Safari/OS X issue or a webkit issue, feel free to close this bug report if that is the case.

Steps to Reproduce:
1. Start up a local server that responds to the host header of &apos;mysite.localhost&apos; on port 8000 (any port is fine)
2. Try to access the site in safari using the url: http://mysite.localhost:8000/

Expected Results:
Every other web browser (Chrome, Firefox, Opera etc..) that I have tested will find the server and load the page as expected. Localhost subdomains don&apos;t seem to be mentioned in any official spec but the fact that they work in every other browser means that people use them for real-world development.

Actual Results:
Safari gives the error &quot;Can&apos;t find server&quot;

Version:
Tested on OS X 10.10 and OS X 10.11 with Safari 9.1.2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1669807</commentid>
    <comment_count>1</comment_count>
    <who name="Irakli Gozalishvili">contact</who>
    <bug_when>2020-07-08 11:04:01 -0700</bug_when>
    <thetext>
https://tools.ietf.org/html/rfc6761 suggests that &quot;localhost&quot; can be treated specially and should hardcode localhost names to the loopback address:

&gt;  &quot;Application software MAY recognize localhost names as special&quot;

and:

&gt;  &quot;Name resolution APIs and libraries SHOULD recognize localhost
&gt;   names as special and SHOULD always return the IP loopback address
&gt;   for address queries and negative responses for all other query
&gt;   types.  Name resolution APIs SHOULD NOT send queries for
&gt;   localhost names to their configured caching DNS server(s).).&quot;


Chrome already support supports / ships this:
https://bugs.chromium.org/p/chromium/issues/detail?id=510124

And firefox is working on this:
https://bugzilla.mozilla.org/show_bug.cgi?id=1220810

It also appears that some of the web platform tests do test for this and were disabled:
https://bugs.webkit.org/show_bug.cgi?id=161142


Any chance of get Safari to get Safari localhost to loopback address ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1701856</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-10-27 06:49:00 -0700</bug_when>
    <thetext>&lt;rdar://problem/70720358&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888203</commentid>
    <comment_count>3</comment_count>
    <who name="Joe Previte">jjprevite</who>
    <bug_when>2022-08-01 14:17:54 -0700</bug_when>
    <thetext>This appears to still be an issue in Safari 15.5

To reproduce:
1. `python -m http.server`
2. Navigate to http://anything.localhost:8000/ in Safari</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891927</commentid>
    <comment_count>4</comment_count>
    <who name="Javier Fernandez">jfernandez</who>
    <bug_when>2022-08-17 05:19:46 -0700</bug_when>
    <thetext>This bug doesn&apos;t affect the WebKitGtk+ port. At least, the test case described in comment c#3 works as expected in the mentioned WebKit port.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892718</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-08-20 15:45:45 -0700</bug_when>
    <thetext>This is mostly something to fix in underlying networking libraries. As long as &quot;ping mysite.localhost&quot; doesn&apos;t work in Terminal, I wouldn&apos;t expect Safari to behave any differently.

WebKit side of this is to make sure that this doesn&apos;t let websites work around any security or privacy mitigations we may have around talking to localhost.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892720</commentid>
    <comment_count>6</comment_count>
    <who name="Xin Liu">livid</who>
    <bug_when>2022-08-20 15:57:02 -0700</bug_when>
    <thetext>If *.localhost can get implemented in the underlying network layer, it would be pretty useful in an IPFS context. Currently, with Chrome, I can access a decentralized website hosted on IPFS + ENS like this:

http://uniswap.eth.ipns.localhost:18181/

http://planetable.eth.ipns.localhost:18181/

In the example above, localhost:18181 is the local IPFS gateway port.

It would be awesome if it could work in Safari too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1895298</commentid>
    <comment_count>7</comment_count>
    <who name="Javier Fernandez">jfernandez</who>
    <bug_when>2022-08-31 15:00:06 -0700</bug_when>
    <thetext>Not only Chrome, but Firefox and any WebKitGtk+ port browser are able to access localhost subdomain (like the test case in comment #3). 

Since Safari is the only one behaving differently, would it make sense to fix this in the Networking layer for the shake of ensuring browser interoperability ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958961</commentid>
    <comment_count>8</comment_count>
    <who name="Andrés">yoseduj</who>
    <bug_when>2023-05-30 23:59:15 -0700</bug_when>
    <thetext>I just came here to say that is May 2023 and in Safari 16.4 is still a problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958962</commentid>
    <comment_count>9</comment_count>
    <who name="Andrés">yoseduj</who>
    <bug_when>2023-05-31 00:00:16 -0700</bug_when>
    <thetext>(In reply to Andrés from comment #8)
&gt; I just came here to say that is May 2023 and in Safari 16.4 is still a
&gt; problem.

This avoid us to properly debug and develop in Safari. Is unfortunate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1960077</commentid>
    <comment_count>10</comment_count>
    <who name="Ian Preston">ianopolous</who>
    <bug_when>2023-06-06 09:34:33 -0700</bug_when>
    <thetext>We also need this for Peergos, another P2P app - https://github.com/Peergos/Peergos/issues/1044

It would be great to support this like Firefox and Chrome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1960126</commentid>
    <comment_count>11</comment_count>
    <who name="Marcin Rataj">lidel</who>
    <bug_when>2023-06-06 13:46:50 -0700</bug_when>
    <thetext>This continues to pose a challenge for IPFS gateway implementations that require Origin isolation (https://specs.ipfs.tech/http-gateways/subdomain-gateway/).

The lack of subdomain support on localhost specifically impacts macOS Safari users, preventing them from achieving per-website Origin isolation and reducing their overall security. Examples in https://github.com/ipfs/in-web-browsers/issues/206

Not supporting localhost subdomain functionality in WebKit introduces a risk for end users, 
particularly in web applications and PWAs that store sensitive user data in localStorage scoped per Origin.

Firefox and Chromium do not encounter this issue since they now bind localhost to the loopback
and bypass the DNS resolver provided by the operating system.
As a result, their users can load websites from the local gateway, where each website has its own Origin:
http://en.wikipedia-on-ipfs.org.ipns.localhost:8080/wiki/
http://bafybeiaysi4s6lnjev27ln5icwm6tueaw2vdykrtjkwiphwekaywqhcjze.ipfs.localhost:8080/wiki/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1973838</commentid>
    <comment_count>12</comment_count>
    <who name="">gulaschsuppe2</who>
    <bug_when>2023-08-27 14:32:01 -0700</bug_when>
    <thetext>For anyone stumbling upon this, subdomains work in safari after you add them in the `/private/etc/hosts/`:

sudo nano /private/etc/hosts

Then add your subdomain:

127.0.0.1 sub.localhost

It is cumbersome, but still helpful if you don&apos;t want to switch away from Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1999524</commentid>
    <comment_count>13</comment_count>
    <who name="Javier Fernandez">jfernandez</who>
    <bug_when>2023-12-14 03:41:04 -0800</bug_when>
    <thetext>Some updates on this bug; the issue is still reproducible in MacOS Ventura 13.4 with Safari 16.5. 

However, it seems it&apos;s not reproducible in MacOS Sonoma 14.2, either with Safari 17.1.2 and Safari Technology Preview 184. 

I assume some changes in MacOS, as suggested in comment #5, have caused this bug to be FIXED, or at least not reproducible any more. Hence, I think we can close this bug now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1999599</commentid>
    <comment_count>14</comment_count>
    <who name="Ryan Hiebert">ryan</who>
    <bug_when>2023-12-14 08:46:36 -0800</bug_when>
    <thetext>I may be missing something, but I&apos;m still reproducing this on Sonoma 14.2 with Safari 17.2 (19617.1.17.11.9). Is it possible that you have adjusted your /etc/hosts file, Javier?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000364</commentid>
    <comment_count>15</comment_count>
    <who name="Javier Fernandez">jfernandez</who>
    <bug_when>2023-12-18 04:11:44 -0800</bug_when>
    <thetext>(In reply to Ryan Hiebert from comment #14)
&gt; I may be missing something, but I&apos;m still reproducing this on Sonoma 14.2
&gt; with Safari 17.2 (19617.1.17.11.9). Is it possible that you have adjusted
&gt; your /etc/hosts file, Javier?

Umm, I admit that further testing made me doubt the issue has been fixed. I need to devote more time to investigate it. 

Reopening for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002370</commentid>
    <comment_count>16</comment_count>
    <who name="Michael FIG">michael+webkit</who>
    <bug_when>2023-12-31 17:35:54 -0800</bug_when>
    <thetext>It seems from my testing that Safari uses macOS&apos;s default DNS resolution for `*.localhost`, which goes like:

1. check /etc/hosts (which doesn&apos;t support wildcards)
2. use the default network DNS server, provided by the network interface settings

This number 2 step is dependent on the good graces of your ISP or router hardware.  Mine happens to resolve `*.localhost`, but that seems to be hit-and-miss, and unrelated to the client macOS version.

You can check yours with `dig example.localhost` for your default DNS server, or `dig @1.1.1.1 example.localhost` for an explicit query to a specific DNS server (like `1.1.1.1` or `8.8.8.8`).

Failed queries look like `status: NXDOMAIN`.  Success has `status: NOERROR` and an `ANSWER SECTION:` with `example.localhost &lt;expiry&gt; IN A 127.0.0.1`.

As mentioned earlier, Firefox and Chromium-based browsers have builtin code that bypasses the default resolution for `*.localhost` and always return `127.0.0.1` in that case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022640</commentid>
    <comment_count>17</comment_count>
    <who name="Sébastien LeBlanc">mrsebastienleblanc</who>
    <bug_when>2024-03-20 21:34:59 -0700</bug_when>
    <thetext>Still not fixed in 2024 on Sonoma 14.4 / Safari 17.4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2117057</commentid>
    <comment_count>18</comment_count>
    <who name="">diogeneshamilton</who>
    <bug_when>2025-05-14 08:53:36 -0700</bug_when>
    <thetext>Just ran into this after switching my main browser to Safari... come on Apple!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2144481</commentid>
    <comment_count>19</comment_count>
    <who name="Jordan Brough">github.j</who>
    <bug_when>2025-09-19 12:34:30 -0700</bug_when>
    <thetext>This seems to be fixed in macOS 26 Tahoe ✅

Repro:

1) Run `python3 -m http.server 8000` from a macOS terminal
2) Visit http://foo.bar.localhost:8000 in Safari

In macOS 15.7: It fails with &quot;Safari can&apos;t find the server &quot;foo.bar.localhost&quot;&quot;
In macOS 26.0: It works 🎉</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2144500</commentid>
    <comment_count>20</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2025-09-19 13:18:38 -0700</bug_when>
    <thetext>Indeed, this was implemented in OS frameworks below WebKit.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>