Microsoft Edge does not allow localhost loopback for websockets

为君一笑 提交于 2019-12-01 04:28:10

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!

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 as of build 14393)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!