# Node red shows Lost connection to server, reconnecting.. beacuse of WebSocket connection to 'wss:// comms' api failed

**URL:** <https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220>\
**Category:** General\
**Created:** [13 April 2022 07:31 UTC](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220 "2022-04-13T07:31:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnyaneshwar](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@dnyaneshwar](https://discourse.nodered.org/u/dnyaneshwar)\
**Post date:** [13 April 2022 07:31 UTC](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220/1 "2022-04-13T07:31:53Z")

</div>

We have created node-red project and that deployed on staging environment, and it is work fine.

But after deploying on production It give following error.

 ![Screenshot 2022-04-13 at 12.52.25 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c3c664cb1902aaacf62579a9d7946bf9fe9a9234.png)

We have checked node-red log and it is also fine,

On server log and browser shows issue with wss:// comms api that run internally by node-red.

 ![Screenshot 2022-04-13 at 12.54.43 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/545699c3c9b51516d571a69e6aa9194368872467.png)

We have allowed TCP on server for websocket but that also not work.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [13 April 2022 09:07 UTC](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220/2 "2022-04-13T09:07:04Z")

</div>

Something in your production environment is blocking the websocket. That's all we can say. If you're running behind a reverse proxy, make sure it allows websockets.

---

<div class="post-metadata">

**Author:** ![dnyaneshwar](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@dnyaneshwar](https://discourse.nodered.org/u/dnyaneshwar)\
**Post date:** [14 April 2022 13:42 UTC](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220/3 "2022-04-14T13:42:46Z")

</div>

we are using ingress controller load balancer where we have allowed tcp protocol in our listener.  
-ingress config map data as follows

proxy-connect-timeout: "30"  
proxy-protocol-header-timeout: "5"  
proxy-read-timeout: "120"  
proxy-send-timeout: "120"  
real-ip-header: proxy\_protocol  
upstream-keepalive-connections: "1000"  
use-forwarded-headers: "true"  
use-proxy-protocol: "true"

---

<div class="post-metadata">

**Author:** ![namph-sgn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/namph-sgn/32/54561_2.png) [@namph-sgn](https://discourse.nodered.org/u/namph-sgn)\
**Post date:** [19 April 2022 10:20 UTC](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220/4 "2022-04-19T10:20:37Z")

</div>

Ok, so I have fixed the websocket issue.  
Some context, I run node-red as embedded in an express server. All my express routes start with /api, so I have to config my settings of Node-RED to reflect that.  
This is my settings. Notice the **httpAdminRoot** and **httpNodeRoot**.

```auto
const settings = {
      httpAdminRoot: '/api/red/admin/',
      httpNodeRoot: '/api/red/',
      userDir: `${os.homedir()}/.nodered/`,
      flowFile: './flows/flows.json',
      flowFilePretty: true,
      functionGlobalContext: {
        lodash: require('lodash'),
        mongodb: require('mongodb'),
      },
      editorTheme: {
        header: {
          title: 'Node-RED',
          image: null,
        },
      },
    };

    RED.init(server, settings);
    this.app.use(settings.httpAdminRoot, RED.httpAdmin);
    this.app.use(settings.httpNodeRoot, RED.httpNode);
    RED.start();

```

So in my nginx config, I took the code from [Using NGINX as a WebSocket Proxy](https://www.nginx.com/blog/websocket-nginx/) and change my config on the remote server to this.

```auto
    location /api/ {
        proxy_pass http://localhost:3000/api/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

```

Now I can access the node-red client at [http://localhost:3000/api/red/admin/](http://localhost:3000/api/red/admin/)  
Hope this help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 June 2022 10:21 UTC](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220/5 "2022-06-18T10:21:09Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
