# Lost Connection to server, reconnecting on AWS linux

**URL:** <https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928>\
**Category:** General\
**Created:** [6 May 2026 23:25 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928 "2026-05-06T23:25:19Z")\
**Posts on this page:** 11\
**Page:** 3

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 May 2026 18:17 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/41 "2026-05-11T18:17:04Z")

</div>

> [@knowledgeshark](#):
>
> If there is a specific web socket port that has to be open

I've told you multiple times now - websockets use the port of the web server that hosts them, they do not have a separate port.

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [11 May 2026 19:35 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/42 "2026-05-11T19:35:04Z")

</div>

From Colin:

> There are tools that you can use to check whether a websocket port is open on a server.

I obviously have the node-red https port open. So if there is no other port for "web socket" then I've done all that I know how to do as an installer of node-red.

Does anyone have a simple program I can try that encompass the node-red setting up a web socket while using the main port (eg 2000)?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 May 2026 19:59 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/43 "2026-05-11T19:59:11Z")

</div>

I generally don't use the stand-alone websockets because I use UIBUILDER which bakes [Socket.IO](http://Socket.IO) into it.

But this should be about as basic as it gets:

```json
[{"id":"7ad569cbdbed633f","type":"websocket in","z":"b2f18a716bd20f99","name":"","server":"51674fc7568039c1","client":"","x":450,"y":1980,"wires":[["11641b147fba7261"]]},{"id":"2b51769d846a2647","type":"websocket out","z":"b2f18a716bd20f99","name":"","server":"51674fc7568039c1","client":"","x":640,"y":2040,"wires":[]},{"id":"11641b147fba7261","type":"debug","z":"b2f18a716bd20f99","name":"debug 38","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":1980,"wires":[]},{"id":"3aa26bc75d8393cc","type":"inject","z":"b2f18a716bd20f99","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":460,"y":2040,"wires":[["2b51769d846a2647"]]},{"id":"51674fc7568039c1","type":"websocket-listener","path":"/myws","wholemsg":"false"}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/715abbb657d021d0ad76e5c13726d5c96edb0c02.png)

(Your path probably won't have the `/nr` on the front, that's just my dev setup).

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 May 2026 20:11 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/44 "2026-05-11T20:11:02Z")

</div>

> [@knowledgeshark](#):
>
> I obviously have the node-red https port open. So if there is no other port for "web socket" then I've done all that I know how to do as an installer of node-red.

As has been suggested multiple times, this is probably nothing to do with node red. The websocket uses the same port as node red, but it is a different protocol. If your AWS instance is not configured to support that then you will get the symptom that you see. Did you try a websocket tester as I suggested?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [11 May 2026 21:28 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/45 "2026-05-11T21:28:08Z")

</div>

Just as a thought, let's look at this from the other end.

If I have understood correctly, the Node-RED instance is running on a AWS EC2 instance that has port 1880 (or some other configured port) open in both the OS firewall and the AWS Security Group.

What about the browser, where is that running, is it always from the same location (e.g. home or an office)?

If an office, does it have any HTTP Proxy enabled (not a reverse proxy on the AWS EC2 machine), but maybe something like Squid?

It may not be explicitly configured, it may be a transparent proxy ennoblement that grabs all outbound HTTP traffic. If this is not enabled for WebSockets then that could also be the problem.

It would also probably be useful to see the browsers network tab in the developer tools, we will be looking for a request to `/comms`

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [12 May 2026 16:20 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/46 "2026-05-12T16:20:10Z")

</div>

This for the ideas.

> If I have understood correctly, the Node-RED instance is running on a AWS EC2 instance that has port 1880 (or some other configured port) open in both the OS firewall and the AWS Security Group.

Yes.

> What about the browser, where is that running, is it always from the same location (e.g. home or an office)?

I have tried various browsers from my iPhone to my normal MacBook - and there are no proxy's on my end.

> It would also probably be useful to see the browsers network tab in the developer tools, we will be looking for a request to /comms

This is the error in my browser:

`WebSocket connection to 'wss://semanticmarkers.com/bot/comms' failed: There was a bad response from the server.`

And the httpd error repeats that:  
`SemanticMarkers.com.request_log-20260510:[08/May/2026:16:25:15 +0000] 75.213.29.86 TLSv1.3 TLS_AES_256_GCM_SHA384 "GET /bot/comms HTTP/1.1" 144`

@TotallyInformation I'm trying the standalone WebSocket now

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [12 May 2026 16:47 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/47 "2026-05-12T16:47:26Z")

</div>

I'm trying a WebSocket flow as a server, and this isn't working. Can you try it from your browser to see if this is the right way to start a websocket server (eg. ws/simple). This goes to my node-red sever.

I'll do some research at the AWS [WebSocket](https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-ip-address-type.html) side as well.

```flows
[
    {
        "id": "e471c1417f0ee229",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e3e4522e.1c1bb",
        "type": "inject",
        "z": "e471c1417f0ee229",
        "name": "Tick every 5 secs",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "test",
        "payload": "",
        "payloadType": "date",
        "x": 270,
        "y": 300,
        "wires": [
            [
                "45dbf990.ba2408"
            ]
        ]
    },
    {
        "id": "50da04b3.af25fc",
        "type": "websocket out",
        "z": "e471c1417f0ee229",
        "name": "",
        "server": "07a7e0858e615378",
        "client": "",
        "x": 740,
        "y": 300,
        "wires": []
    },
    {
        "id": "42a28745.bd5d78",
        "type": "http response",
        "z": "e471c1417f0ee229",
        "name": "",
        "x": 721,
        "y": 240,
        "wires": []
    },
    {
        "id": "1787be40.e87842",
        "type": "http in",
        "z": "e471c1417f0ee229",
        "name": "",
        "url": "/simple",
        "method": "get",
        "swaggerDoc": "",
        "x": 352,
        "y": 240,
        "wires": [
            [
                "1857548e.e7a8ab"
            ]
        ]
    },
    {
        "id": "1857548e.e7a8ab",
        "type": "template",
        "z": "e471c1417f0ee229",
        "name": "Simple Web Page",
        "field": "payload",
        "fieldType": "msg",
        "format": "html",
        "syntax": "mustache",
        "template": "<!DOCTYPE HTML>\n<html>\n <head>\n <title>Simple Live Display</title>\n <script type=\"text/javascript\">\n var ws;\n var wsUri = \"ws:\";\n var loc = window.location;\n console.log(loc);\n if (loc.protocol === \"https:\") { wsUri = \"wss:\"; }\n // This needs to point to the web socket in the Node-RED flow\n // ... in this case it's ws/simple\n wsUri += \"//\" + \"SemanticMarkers.com/bot/ws/simple\";\n console.log(wsUri);\n\n function wsConnect() {\n console.log(\"connect\",wsUri);\n ws = new WebSocket(wsUri);\n //var line = \"\"; // either uncomment this for a building list of messages\n ws.onmessage = function(msg) {\n var line = \"\"; // or uncomment this to overwrite the existing message\n // parse the incoming message as a JSON object\n var data = msg.data;\n console.log(data);\n // build the output from the topic and payload parts of the object\n line += \"<p>\"+data+\"</p>\";\n // replace the messages div with the new \"line\"\n document.getElementById('messages').innerHTML = line;\n //ws.send(JSON.stringify({data:data}));\n }\n ws.onopen = function() {\n // update the status div with the connection status\n document.getElementById('status').innerHTML = \"connected\";\n ws.send(\"Open for data\");\n console.log(\"connected\");\n }\n ws.onclose = function() {\n // update the status div with the connection status\n document.getElementById('status').innerHTML = \"not connected\";\n // in case of lost connection tries to reconnect every 3 secs\n setTimeout(wsConnect,3000);\n }\n ws.disconnect = function() {\n console.log(\"Disconnected\");\n document.getElementById('status').innerHTML = \"disconnected\";\n }\n }\n \n function doit(m) {\n if (ws) { ws.send(m); }\n }\n </script>\n </head>\n <body onload=\"wsConnect();\" onunload=\"ws.disconnect();\">\n <font face=\"Arial\">\n <h1>Simple Live Display</h1>\n <div id=\"messages\"></div>\n <button type=\"button\" onclick='doit(\"click\");'>Click to send message</button>\n <hr/>\n <div id=\"status\">unknown</div>\n </font>\n </body>\n</html>\n",
        "x": 549,
        "y": 240,
        "wires": [
            [
                "42a28745.bd5d78"
            ]
        ]
    },
    {
        "id": "45dbf990.ba2408",
        "type": "function",
        "z": "e471c1417f0ee229",
        "name": "format time nicely",
        "func": "msg.payload = Date(msg.payload).toString();\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 510,
        "y": 300,
        "wires": [
            [
                "50da04b3.af25fc",
                "9095309e5a6340c9"
            ]
        ]
    },
    {
        "id": "eccc8bc2.133378",
        "type": "websocket in",
        "z": "e471c1417f0ee229",
        "name": "",
        "server": "07a7e0858e615378",
        "client": "",
        "x": 460,
        "y": 380,
        "wires": [
            [
                "9adfff59.652"
            ]
        ]
    },
    {
        "id": "9adfff59.652",
        "type": "debug",
        "z": "e471c1417f0ee229",
        "name": "Received Websocket /ws/simple",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 740,
        "y": 380,
        "wires": []
    },
    {
        "id": "9095309e5a6340c9",
        "type": "debug",
        "z": "e471c1417f0ee229",
        "name": "Sent Websocket /ws/simple",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 320,
        "wires": []
    },
    {
        "id": "07a7e0858e615378",
        "type": "websocket-listener",
        "path": "/ws/simple",
        "wholemsg": "false"
    }
]

```

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [12 May 2026 17:02 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/48 "2026-05-12T17:02:21Z")

</div>

OK .. this is interesting. I do NOT get the lost connection if I use the PORT number, versus my http rewrite.

So [SemanticMarkers.com:2000](http://SemanticMarkers.com:2000) (works)  
vs `SemanticMarkers.com/bot`

The Rewrite rule is:

```auto
# node-red
   # /bot-> :2000
   RewriteRule ^/bot$ bot/ [L,R=301]
   ProxyPass "/bot" "https://SemanticMarkers.com:2000"
   ProxyPassReverse "/bot" "https://SemanticMarkers.com:2000"

```

So I think this is an Apache HTTPD server issue. For example this: [Apache ProxyPass websocket problem · Issue #3339 · meteor/meteor · GitHub](https://github.com/meteor/meteor/issues/3339)  
and

> Apache `mod_rewrite` often breaks WebSockets because it doesn't automatically handle the "Upgrade" mechanism that switches a connection from HTTP to the WebSocket protocol. Standard rewrite rules typically treat WebSocket handshakes as regular HTTP requests, which can lead to dropped connections or "400 Bad Request" errors. [[1](https://github.com/meteor/meteor/issues/3339), [2](https://stackoverflow.com/questions/12064882/apache-redirect-rules-for-back-end-server-with-websockets), [3](https://medium.com/@speaktoharisudhan/understanding-websockets-and-why-they-are-preferred-over-http-requests-ed9dba297cdf), [4](https://oneuptime.com/blog/post/2025-12-16-websocket-400-bad-request-nginx/view)]

Thanks so much..

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2026 19:18 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/49 "2026-05-12T19:18:07Z")

</div>

> [@knowledgeshark](#):
>
> Apache `mod_rewrite`

> [@knowledgeshark](#):
>
> I'm using HTTPS, have no proxy servers, and I don't see any "Load Balancers" on my AWS site.

😡

So this is a proxy that I warned you about - I think in my very first response. But you never told us that you'd put a proxy in front of everything even though we asked repeatedly.

And to be clear, not a Node-RED issue at all.

When asking for help, please be clear about your environment - and take care to listen to advice and work through it carefully.

---

<div class="post-metadata">

**Author:** ![knowledgeshark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knowledgeshark/32/4820_2.png) [@knowledgeshark](https://discourse.nodered.org/u/knowledgeshark)\
**Post date:** [12 May 2026 19:28 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/50 "2026-05-12T19:28:08Z")

</div>

Thanks for the help. I wasn't thinking "proxy" but rather "rewrite" since they are using the httpd server. I assumed a proxy was a separate process (other than httpd).

Thanks, everyone.

---

<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:** [26 May 2026 19:28 UTC](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928/51 "2026-05-26T19:28:53Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/lost-connection-to-server-reconnecting-on-aws-linux/100928.md?page=2)
