Node-red dashboard "refused to connect"

I am having a problem with my node-red. I am running node-red on a windows 10 PC and using node-red-dashboard as UI. The problem is that sometimes when I get power outage, the node-red stops working. In the browser it says "refused to connect", to the adress 128.1.11.3:1880/ui/.
How I solve the problem:
I delete the context folder in the node-red folder.
Then I restart the PC and starting node-red.

What could cause this problem?
How should I locate the problem so I can get rid of this?

Welcome to the forum @larro96

Is node-red running? Can you connect to the editor at 128.1.11.3:1880?

Does that fix it? If not show us what you see in the command window when you start node-red.

If that does fix it, does just restarting node-red fix it (without clearing the context)? If not then, again, show us what you get in the command window when you restart node-red.

Node-red is running and I can connect to the editor.

My solution is solving the problem, just restarting node-red doesn't.
I'll get some screenshots next time it crashes.

No, copy/paste the output please.

1 Like

Here is the output:
Your environment has been set up for using Node.js 18.15.0 (x64) and npm.

C:\Users\Pc>node-red
27 May 06:33:35 - [info]

Welcome to Node-RED
===================

27 May 06:33:35 - [info] Node-RED version: v3.0.2
27 May 06:33:35 - [info] Node.js  version: v18.15.0
27 May 06:33:35 - [info] Windows_NT 10.0.19045 x64 LE
27 May 06:33:38 - [info] Loading palette nodes
27 May 06:33:44 - [info] Dashboard version 3.4.0 started at /ui
27 May 06:33:44 - [info] Settings file  : C:\Users\Pc\.node-red\settings.js
27 May 06:33:44 - [info] Context store  : 'default' [module=localfilesystem]
27 May 06:33:44 - [error] Failed to start server:
27 May 06:33:44 - [error] Error: Error loading context store: Error: Invalid JSON in context file '\Users\Pc\.node-red\context\b1531b115956bc02\dcea7f832804799a.json'
    at C:\Users\Pc\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\context\index.js:180:15

C:\Users\Pc>node-red
27 May 06:36:12 - [info]

Welcome to Node-RED
===================

27 May 06:36:12 - [info] Node-RED version: v3.0.2
27 May 06:36:12 - [info] Node.js  version: v18.15.0
27 May 06:36:12 - [info] Windows_NT 10.0.19045 x64 LE
27 May 06:36:15 - [info] Loading palette nodes
27 May 06:36:20 - [info] Dashboard version 3.4.0 started at /ui
27 May 06:36:20 - [info] Settings file  : C:\Users\Pc\.node-red\settings.js
27 May 06:36:20 - [info] Context store  : 'default' [module=localfilesystem]
27 May 06:36:20 - [error] Failed to start server:
27 May 06:36:20 - [error] Error: Error loading context store: Error: Invalid JSON in context file '\Users\Pc\.node-red\context\b1531b115956bc02\dcea7f832804799a.json'
    at C:\Users\Pc\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\context\index.js:180:15

C:\Users\Pc>node-red
27 May 06:41:40 - [info]

Welcome to Node-RED
===================

27 May 06:41:40 - [info] Node-RED version: v3.0.2
27 May 06:41:40 - [info] Node.js  version: v18.15.0
27 May 06:41:40 - [info] Windows_NT 10.0.19045 x64 LE
27 May 06:41:43 - [info] Loading palette nodes
27 May 06:41:49 - [info] Dashboard version 3.4.0 started at /ui
27 May 06:41:49 - [info] Settings file  : C:\Users\Pc\.node-red\settings.js
27 May 06:41:49 - [info] Context store  : 'default' [module=localfilesystem]
27 May 06:41:49 - [error] Failed to start server:
27 May 06:41:49 - [error] Error: Error loading context store: Error: Invalid JSON in context file '\Users\Pc\.node-red\context\backup 240527\dcea7f832804799a.json'
    at C:\Users\Pc\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\context\index.js:180:15

C:\Users\Pc>node-red
27 May 06:42:10 - [info]

Welcome to Node-RED
===================

27 May 06:42:10 - [info] Node-RED version: v3.0.2
27 May 06:42:10 - [info] Node.js  version: v18.15.0
27 May 06:42:10 - [info] Windows_NT 10.0.19045 x64 LE
27 May 06:42:12 - [info] Loading palette nodes
27 May 06:42:18 - [info] Dashboard version 3.4.0 started at /ui
27 May 06:42:18 - [info] Settings file  : C:\Users\Pc\.node-red\settings.js
27 May 06:42:18 - [info] Context store  : 'default' [module=localfilesystem]
27 May 06:42:18 - [info] User directory : \Users\Pc\.node-red
27 May 06:42:18 - [warn] Projects disabled : editorTheme.projects.enabled=false
27 May 06:42:18 - [info] Flows file     : \Users\Pc\.node-red\flows.json
27 May 06:42:18 - [info] Server now running at http://127.0.0.1:1880/
27 May 06:42:19 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

27 May 06:42:19 - [info] Starting flows
Connection options, transport settings: {}
Connection options, transport settings: {}
Connection options, transport settings: {}
Connection options, transport settings: {}
27 May 06:42:19 - [info] Started flows
04:42:25.194Z :populate_data_type_manager_104:51     Cannot find dataType Definition ! with nodeId =ns=2;i=6525
04:42:25.592Z :populate_data_type_manager_104:51     Cannot find dataType Definition ! with nodeId =ns=2;i=15889
04:42:25.600Z :populate_data_type_manager_104:51     Cannot find dataType Definition ! with nodeId =ns=2;i=15888

The problem apeared when the pc was turned off during the weekend and then was started this morning.

Can you locate the problem in the output I posted?

I have editted your post to add tripple backticks around the output so that the forum does not interpret it a markdown.

Did you do anything between those run attempts? If you did not then the file system is not giving you consistent data so you have something very wrong with your system. I don't know much about Windows so can't really help much with that. You probably want to make sure everything is backed up and then run a check disk operation.

Thanks,
for the first three attempts I tried to delete different files in the folder "C:\Users\Pc\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\runtime\lib\nodes\context" but it didn't help.
Last time I deleted the files inte the folder "\Users\Pc.node-red\context" and then it starts without problem.

Deleting anything inside "C:\Users\Pc\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\*** will break Node-RED! Those are the actual source code files that makes Node-RED run (they are not data files that can be simply cleaned up!)

Understood.

Do you have any solution on my problem?