7

I have web-site and desktop application, and I want to connect them by websockets. So my web-site tries to connect to wss://localhost:8080, for example.

It works in IE11, but in "MS Edge" I have an error:

Cross zone request is not allowed

I have this problem on Win10 10240, so the flag "Allow localhost loopback" is enabled by default, and it did not help.

When I use CheckNetIsolation LoopbackExempt -a -n="Microsoft.MicrosoftEdge_8wekyb3d8bbwe" or this utility, all works as expected.

So, is this a case, that in new builds of "MS Edge" loopbacks are allowed for http, but not allowed for websockets? And if so, is it possible to make some workaround, and not to force my users to run some shell comand or to download externall utility?

Related question: Can't open localhost in Microsoft Edge (Project Spartan) in Windows 10 preview

Community
  • 1
  • 1
azaviruha
  • 896
  • 1
  • 7
  • 14

3 Answers3

6

In the Microsoft Edge browser type "About:flags" in the title bar (search bar). No quotes, Tick/Un-tick the "allow Localhost Loopback" feature.

Edge on Win Build 10240. (still works upto New Edge (chrome based))

Narcarsiss
  • 71
  • 4
  • 2
    Also available in the registry here: `HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\ExperimentalFeatures\AllowLocalhostLoopback` and, yes, the ugly `8wekyb3d8bbw` part of the registry key is perfectly valid, it is Microsoft's unique developer ID which occurs hundreds of times in the registry. – tresf Sep 29 '15 at 16:23
  • 1
    When Edge was first released, this worked. Now you need to use `CheckNetIsolation` command. – tresf Jul 10 '18 at 01:46
  • these options dont see to be there anymore with Edge. anyone know what the latest option to allow access to localhost? – mike01010 Jul 14 '23 at 15:54
5

After some research I found the source of error. Here is my repo, to reproduce error: https://github.com/AZaviruha/ms-edge-ws-strange

In short, when you call new WebSocket in MS Edge, it does not generate exception, when you call it with wrong "local"-host argument:

var socket, path;
var hosts = ['localhost', '127.0.0.1'];

for (var i in hosts) {
    path = 'ws://'+hosts[i]+':9446';
    console.log( '===> Tested path :: ', path );
    try {
        socket = new WebSocket( path );
        break;
    }
    catch ( e ) {
        // !!! Never shown !!!
        console.error( '===> WebSocket creation error :: ', e );
    }
}

Because of this, you can't "retry" to connect with different hosts.

By the way, if you try non-local non-existent host, it will generate exception!

azaviruha
  • 896
  • 1
  • 7
  • 14
1

This recently happened to me again after doing the Windows 10 Creator's Update (1703).

But the fix was easy. I had to

  1. Check the "allow Localhost Loopback" feature mentioned by @Narcarsiss (not sure if that got disabled in the update, or I just never checked it myself previously).
  2. Specify the protocol in the address bar (http://localhost:5000/ instead of just localhost:5000/).

After doing both I was able to access my localhost sites again in MS Edge.