Node-RED "loses" flows

Folks,

I have Node-RED running on a Raspberry Pi 3 at home. I have some flows in which data coming in via MQTT (the broker is on the same Raspberry Pi) is sent on to Thingspeak and to an InfluxDB database.

A strange phenomenon has popped up recently, not sure if it is actually a Node-RED thing or a general Raspberry Pi filesystem thing.

I find that if the Pi is restarted (e.g. after a power failure or shutdown), on restart, Node-RED seems to have "lost" some of my most recent flows (i.e. the parts of flows I've most recently added). I can manually put them back in and Deploy and everything works well, but the next time there is a power failure or shutdown, they're gone again.

Anyone have an idea of what the origin of this might be?

Does the hostname of your pi change when it comes back with the new network connection? The default flow is linked to the hostname, but you can set it in the command to run a specific one. It’s in the User Guide in the docs. Sorry, too tired to link it directly but I believe you can find it as part of Configuring Node-RED.

In a terminal, change to your .node-red directory and list the files

Also check that if you save a file (any file) and then do a full power off and restart that the file is still there. I had a card recently that appeared to function perfectly, but it never actually saved anything to its flash memory so they were all lost on restart.

1 Like

It does sound like (as @Colin says) that your card has gone read-only (which is what happens at end of its life)

And very confusing it was too. I had updated some flows and then the system ran fine for many weeks till a power fail caused the flows to revert. It then took several hours trying to understand what was going on before I realised and ditched the card. I then was very glad I had a recent image backup.

1 Like

Thanks to all of you. Shortly after submitting my question, I started to see other strange behaviour on the Pi that (after consulting online) is also linked to failure of the SD card.

I replaced it with a new SD card (my setup is minimal so it didn't take long to reconfigure) and now all is well.

1 Like

SD-Card failures used to be common on the Pi. But if you use a good quality SD-Card (like the Samsung EVO and EVO Pro) and make sure it is much bigger than you need (say 32GB+), then it should run reliably for years even with the occasional power failure or unexpected reboot.

I can no longer even remember the last time I had to replace a card. Certainly at least 2 years ago, probably longer and I have a Pi2 and a Pi3 running 24x7x365.

The reason for using a larger card is to allow lots of room for wear levelling.

1 Like