Excel JS add-in communicate with localhost via websockets RRS feed

  • Question

  • We are attempting to communicate from within an Excel 365 add-in (Javascript) to our application written in C++/Qt using websockets. The application is running on the local computer and operates as a secure websockets server with a self-signed certificate.

    I can establish a websockets connection from Edge or Chrome to our local application, but cannot establish one from with the Excel add-in. Is there a security policy or similar which prevents Excel / Office JS add-ins from making a connection to localhost /

    It seems to be similar to the "Allow localhost loopback" setting in Edge, so I wondered if Office enforces that for additional security. If so, can it be disabled?

    Simple communication testing code:

    if ("WebSocket" in window) {
            console.log("WebSocket is supported by your Browser!");
            // Let us open a web socket
            var ws = new WebSocket("wss://localhost:8080");
            ws.onopen = function () {
                // Web Socket is connected, send data using send()
                ws.send("Message to send");
                console.log("Message is sent...");
            ws.onmessage = function (evt) {
                var received_msg =;
                console.log("Message is received...");
            ws.onclose = function () {
                // websocket is closed.
                console.log("Connection is closed...");
        } else {
            // The browser doesn't support WebSocket
            console.log("WebSocket NOT supported by your Browser!");

    Wednesday, February 13, 2019 7:56 PM

All replies

  • Hi, did you found any solution for this? I have the same issue, in addition, in excel online works perfect, but in excel form desktop it does not... I would be very grateful even if you discover that it was not possible
    Wednesday, June 17, 2020 4:49 AM