# Get 502 Bad Gateway from HA while selecting Node-RED

**URL:** https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831
**Category:** General
**Created:** [22 February 2022 17:52 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831 "2022-02-22T17:52:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![SWAXXIII](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@SWAXXIII](https://discourse.nodered.org/u/SWAXXIII)
#### Post date: [22 February 2022 17:52 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831/1 "2022-02-22T17:52:27Z")

</div>

I have been using Node-RED for a couple of months and love it. Unfortunately, I can no longer access it; I get 502 Bad Gateway nginx. The two newest changes I made were upgrading to the latest release of Node-RED and creating a new flow. I don't know why either of these things would cause this problem. It seems as though Node-RED keeps restarting because of a poll-state.status.error (listed below).`  
I am totally lost so any help would be greatly appreciated.``

Errors in my log include:  
[error] [poll-state:North Stairs Sprinker System] poll-state.errors.offset\_nan  
[error] Error: poll-state.status.error at PollState.getInterval (/opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/nodes/poll-state/controller.js:127:19)  
[info] [server:Home Assistant] Connecting to [http://supervisor/core](http://supervisor/core)  
TCP 192.168.1.136:9999 Error: connect ECONNREFUSED 192.168.1.136:9999  
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {  
errno: -111,  
code: 'ECONNREFUSED',  
syscall: 'connect',  
address: '192.168.1.136',  
port: 9999  
`  
[error] Error: poll-state.status.error  
at PollState.getInterval (/opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/nodes/poll-state/controller.js:127:19)  
at PollState.onIntervalUpdate (/opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/nodes/poll-state/controller.js:132:31)  
at EventEmitter.emit (node:events:532:35)  
at /opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/Websocket.js:223:27  
[09:44:22] INFO: Starting Node-RED...

> start  
> node $NODE\_OPTIONS node\_modules/node-red/red.js "--settings" "/etc/node-red/config.js"  
> 22 Feb 09:44:26 - [info]  
> Welcome to Node-RED  
> ===================  
> 22 Feb 09:44:26 - [info] Node-RED version: v2.2.1  
> 22 Feb 09:44:26 - [info] Node.js version: v16.14.0  
> 22 Feb 09:44:26 - [info] Linux 5.10.92-v8 arm64 LE  
> 22 Feb 09:44:28 - [info] Loading palette nodes  
> 22 Feb 09:44:36 - [info] Dashboard version 3.1.5 started at /endpoint/ui  
> 22 Feb 09:44:37 - [info] Settings file : /etc/node-red/config.js  
> 22 Feb 09:44:37 - [info] Context store : 'default' [module=memory]  
> 22 Feb 09:44:37 - [info] User directory : /config/node-red/  
> 22 Feb 09:44:37 - [warn] Projects disabled : editorTheme.projects.enabled=false  
> 22 Feb 09:44:37 - [info] Flows file : /config/node-red/flows.json  
> 22 Feb 09:44:38 - [info] Server now running at [http://127.0.0.1:46836/](http://127.0.0.1:46836/)  
> 22 Feb 09:44:38 - [info] Starting flows  
> 22 Feb 09:44:39 - [info] Started flows  
> 22 Feb 09:44:39 - [info] [server:Home Assistant] Connecting to [http://supervisor/core](http://supervisor/core)  
> 22 Feb 09:44:39 - [info] [server:Home Assistant] Connected to [http://supervisor/core](http://supervisor/core)  
> 22 Feb 09:44:40 - [error] [poll-state:North Stairs Sprinker System] poll-state.errors.offset\_nan  
> 22 Feb 09:44:40 - [red] Uncaught Exception:  
> 22 Feb 09:44:40 - [error] Error: poll-state.status.error  
> at PollState.getInterval (/opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/nodes/poll-state/controller.js:127:19)  
> at PollState.onIntervalUpdate (/opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/nodes/poll-state/controller.js:132:31)  
> at EventEmitter.emit (node:events:532:35)  
> at /opt/node\_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/Websocket.js:223:27  
> at processTicksAndRejections (node:internal/process/task\_queues:96:5)  
> [09:44:40] INFO: Starting Node-RED...

---

<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: [22 February 2022 21:14 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831/2 "2022-02-22T21:14:02Z")

</div>

Welcome to the forum @SWAXXIII

Home Assistant is little used by those here, and that appears to an HA problem rather than node-red, so you might be better off asking in a Home Assistant forum. There appears to be a bug in Poll State node (whatever that is), since no user error with a node should cause it to crash node-red.

---

<div class="post-metadata">

### Author: ![SWAXXIII](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@SWAXXIII](https://discourse.nodered.org/u/SWAXXIII)
#### Post date: [23 February 2022 00:29 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831/3 "2022-02-23T00:29:05Z")

</div>

Isn't the **[red] uncaughtException** error a node red error or bug?

---

<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: [23 February 2022 00:34 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831/4 "2022-02-23T00:34:48Z")

</div>

@SWAXXIII no. It is a bug with the HA websocket node not handling it's errors properly.

Node-RED cannot swallow async errors as if they didn't happen. Nodes need to handle them otherwise they leave the system in an unknown state and the only safe option is to restart.

---

<div class="post-metadata">

### Author: ![SWAXXIII](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@SWAXXIII](https://discourse.nodered.org/u/SWAXXIII)
#### Post date: [23 February 2022 03:10 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831/5 "2022-02-23T03:10:12Z")

</div>

Okay, thanks! I will try to get some help on the HA side.

---

<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: [24 April 2022 03:10 UTC](https://discourse.nodered.org/t/get-502-bad-gateway-from-ha-while-selecting-node-red/58831/6 "2022-04-24T03:10:58Z")

</div>

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