Unable access node-red via browser

Hello to all,
I'm not able access node-red via browser due to my context storage error. Below error
shown when running node-red from cli.

"$ node-red start
10 Dec 15:04:53 - [info]

Welcome to Node-RED

10 Dec 15:04:53 - [info] Node-RED version: v2.1.1
10 Dec 15:04:53 - [info] Node.js version: v14.18.1
10 Dec 15:04:53 - [info] Linux 3.4.39 arm LE
10 Dec 15:04:54 - [info] Loading palette nodes
10 Dec 15:04:58 - [info] Dashboard version 3.0.4 started at /ui
10 Dec 15:04:58 - [info] Settings file : /home/htnice/.node-red/settings.js
10 Dec 15:04:58 - [info] Context store : 'memoryOnly' [module=memory]
10 Dec 15:04:58 - [info] Context store : 'file' [module=localfilesystem]
10 Dec 15:04:58 - [error] Failed to start server:
10 Dec 15:04:58 - [error] Error: Error loading context store: Error: Invalid JSON in context file '/home/htnice/.node-red/context/e9667f131763216a/flow.json'
at /usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/context/index.js:175:15
$
"
How do i revert back to last good condition stage?
Appreciate anyone can help.
Thank you

I thought the command was node-red-start not - as you how it: node-red start

$ node-red-start
-sh: 252: node-red-start: not found

Ok, in what directory are you entering the command?

Who installed Node-red? (You or root)?

Seeing the $ I'm guessing you are using ubuntu/linux.

If you have not installed using the recommended Ubuntu/Debian/Pi script then the command to start node red using the default flow file is
node-red
Adding start tells it to use a flow file called start.
Assuming it still fails using node-red then delete the file it is complaining about, which appears to be corrupted. Did you have a power failure? That is the sort of situation that might cause the corruption. The file contains flow context data.
In fact rather than delete, move it somewhere and see what is in it. Restart node red after moving it.

What happens if you just type node-red in the terminal?

Hi @zyx09

The error in the log tells you exactly what the issue is.

You have file context enabled, and somehow one of the store files has invalid JSON in it.

Have a look at the json file mentioned in the error message.

The quick fix will be to remove that file - you will lose whatever context data had been saved for that flow, but if the file is bad, then it's probably already lost.

Thank you and Colin reply.

I dun mind lose all context data had been saved. As long i can access node-red to continue

my development.

I will try it and you update.

Again thanks a lot

It's work, now can access node-red via browser.

But not only data lost. I had few flows tab also lost too.

Can you point me where can i learn how to backup all flows and node-red settings files to my

laptop, Instead leave it at controller.

thanks.

Does the fact that you have marked this as the solution mean that you do not need the question there answered?

Just in case, you should backup the whole of the .node-red folder except for the node_modules folder, which may be very large.

The fact that you lost more than just the context file is worrying. In your situation I would probably discard the SD card, or at least only use it on non-critical systems, as there is a possibility that it may be failing. Also make sure you are using a good quality power supply.

Thanks your valuable information.

maybe you didn't lose your flows ?

  1. how did you start node-red after you fixed the problem with the corrupt Context file ?
    With node-red ?
  2. show us the list of .json files from your .node-red folder ?

If you did use node-red start as originally posted you may well also have a file called start or start.json that may contain a version of your flows - whether it is worth saving will require some careful digging - but first backup the files as Colin suggested.

@UnborN & @dceejay Thank you for both reply and help.

Hello UnborN,
I setup systmectl enable node-red.service to startup my node-red application when controller is power up. By default it will run flows.json.

Here is my json files. Unfortunately i already deleted that corrupt flows.json and flows.json.backup which on date 09 Dec. The rest of json files still in good condition.

I did open that 2 corrupt json files, all it shown "^@Q^@Q^@Q^@Q.........".

Hi dceejay,
I tried search "start.json" with command 'find -type f -iname "start.json",
but it reported all are permission denied, as shown below

$ find / -type f -iname "start.json"
find: '/lost+found': Permission denied
find: '/proc/tty/driver': Permission denied
find: '/proc/1/task/1/fd': Permission denied
find: '/proc/1/task/1/fdinfo': Permission denied
find: '/proc/1/task/1/ns': Permission denied"
...

Why did you delete the actual flow files? Nobody suggested to do that.
The discussion and suggestions was to backup the .node-red folder
and then remove the Context file '/home/htnice/.node-red/context/e9667f131763216a/flow.json'

Anyway .. i think the only chance to salvage anything is from that flows.json.bak1 file with Date Nov 5

Open it with a text editor .. copy its contents and paste in the Node-red Editor Import window (Ctrl-I)

learn the painful lesson... :cry:

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