Node-RED keeps restarting after updates :(

Hi everybody,

so I didn’t update HA for quite a while. Now I did and everything is blown apart.

Beside some other annoying problems with custom components that aren’t loaded any more and stuff like that the most important one is to get Node-RED up again.

I always get 502 Bad Gateway and in the logs I note that it keeps restarting all the time:

[10:51:33] INFO: Starting Node-RED...
> addon-node-red@ start /opt
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"
6 Jun 10:51:36 - [info] 
Welcome to Node-RED
===================
6 Jun 10:51:36 - [info] Node-RED version: v1.0.6
6 Jun 10:51:36 - [info] Node.js  version: v12.15.0
6 Jun 10:51:36 - [info] Linux 5.4.42-v7l arm LE
6 Jun 10:51:37 - [info] Loading palette nodes
6 Jun 10:51:41 - [info] Dashboard version 2.22.1 started at /endpoint/ui
Traceback (most recent call last):
  File "/opt/node_modules/node-red-node-pi-gpio/testgpio.py", line 4, in <module>
    import RPi.GPIO as GPIO
  File "/usr/lib/python2.7/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
6 Jun 10:51:42 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
6 Jun 10:51:42 - [info] Settings file  : /etc/node-red/config.js
6 Jun 10:51:42 - [info] Context store  : 'default' [module=memory]
6 Jun 10:51:42 - [info] User directory : /config/node-red/
6 Jun 10:51:42 - [warn] Projects disabled : editorTheme.projects.enabled=false
6 Jun 10:51:42 - [info] Flows file     : /config/node-red/flows.json
6 Jun 10:51:42 - [info] Server now running at http://127.0.0.1:46836/
6 Jun 10:51:42 - [info] Starting flows
6 Jun 10:51:43 - [info] Started flows
6 Jun 10:51:43 - [red] Uncaught Exception:
6 Jun 10:51:43 - Api Error: Unexpected response status; 404
    at requireStatusCode200 (/config/node-red/node_modules/node-hue-api/hue-api/httpPromise.js:100:15)
    at _fulfilled (/config/node-red/node_modules/q/q.js:787:54)
    at /config/node-red/node_modules/q/q.js:816:30
    at Promise.promise.promiseDispatch (/config/node-red/node_modules/q/q.js:749:13)
    at /config/node-red/node_modules/q/q.js:557:44
    at flush (/config/node-red/node_modules/q/q.js:108:17)
    at processTicksAndRejections (internal/process/task_queues.js:76:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! addon-node-red@ start: `node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the addon-node-red@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-06T08_51_43_992Z-debug.log
[10:51:44] INFO: Starting Node-RED...

Any suggestions?

Not sure if this helps… but I had “some” of this related errors a while ago and it turned out DNS was my issue… Do you use pihole, or other DNS altering stuff? Try to give home assistant “clean” DNS access then. I think for me it had to do it was not able to download “node-red” updates or some sort of that.

No, I don’t do anything like that.

I would like to try an uninstall / reinstall of Node-RED but what will happen to my flows, will they be gone of I uninstall NR on a hassio setup? Any way to export them without NR running?

Reinstallation brought no success. The message indicates that it is a problem with the hue api. But how can I remove that in the hassio addon without being able to enter the webinterface?

I got this fixed.

Problem: I installed some Palette Nodes for Hue, one of those installed the node-hue-api.

Solution:
Save node-red folder from config.
Uninstall Node-Red addon
Delete Node-Red folder from config
Put flow.json from backed up Node-Red folder to the new Node-Red installation
In my case: Reinstall the only custom node currently in use from palette managment (throttle).

What I learned from this is to use as few custom nodes / stuff as possible. In this case the nodes installed many dependencies which had a lot of deprecated stuff after updating my installation…

I’ve learnt the hard way that it’s best to configure one addon for node red at a time. Set it up restart and verify all is well so that way if anything does not work just uninstall the last addon and go again.

You are right. The problem just was that they were all running good but I didn’t upgrade quite a while. After updating quite a few versions at once one component was not working anymore and preventing Node RED from starting so I couldn’t remove it.

However, solved now :slight_smile: