# 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:** 1\
**Showing post:** 4

<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.

---

_[View the full topic](https://discourse.nodered.org/t/node-red-shows-lost-connection-to-server-reconnecting-beacuse-of-websocket-connection-to-wss-comms-api-failed/61220)._
