How to fix broken Node-RED flows?

Node-RED is a popular open-source flow-based programming tool that allows users to create and deploy applications. However, if your Node-RED flows are stuck in an endless loop of crashing, it can be frustrating to troubleshoot. In this guide, we will explain how to recover your Node-RED flows by booting Node-RED in safe mode.

Problem

There could be several reasons why the Node-RED flow is going into a loop, such as a misconfigured node, especially azure-iot-hub and python3-function

Solution

To boot Node-RED in safe mode, you will need to change the environment variable NODE_RED_ENABLE_SAFE_MODE to true. Follow the instructions below depending on your version of Node-RED:

After 0.6.1

  1. Using UMHLens, connect to the cluster and select the namespace where Node-RED is located.
  2. Go to Apps > Releases and select your releases.
  3. Search for NODE_RED_ENABLE_SAFE_MODE and change the value from false to true.
  4. Save the changes.

If you receive an error message saying RELEASE not found in UMHLens / OpenLens while saving, follow this guide to fix it.

Before 0.6.1

  1. Using UMHLens, connect to the cluster and select the namespace where Node-RED is located.
  2. Select the StatefulSet Node-RED. A popup should appear on the right side.
  3. Press the edit button / pen symbol on top right of the screen.
  4. Find the line env: and add the following underneath it:
- name: NODE_RED_ENABLE_SAFE_MODE
  value: "true"
  1. Press save.

  2. If necessary, terminate the pod manually (or if you are impatient).

  3. Node-RED should now start in safe mode, which means it will boot but not execute any flows.

  4. Make your changes and fix the nodes.

  5. Repeat steps 1-5, but this time set NODE_RED_ENABLE_SAFE_MODE to false.