# RPi hangs/freezes after running a few days

**URL:** https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381
**Category:** General
**Created:** [6 October 2019 10:59 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381 "2019-10-06T10:59:41Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [6 October 2019 10:59 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/1 "2019-10-06T10:59:41Z")

</div>

Hi, I've done a Node-red code for a home automated ventilation system - that freezes after running a few days ☹

I have tested changing the update interval of some of my nodes (data reads and date/time updates etc.) - I did a change of all data being updated every second to all data being updated less often - I think 10secs - that upped the run time from approx a day to a few days. However, it still freezes eventually.  
Its as if the UI dashboard cannot be loaded, or seems to load as a blank page..

Its a RasPi 4. I have monitored memory, which seems to be consistently way below the 4Gigs of RAM. I have added a (noisy) fan and opened the case, keeping temps low at 30degree celcius.  
However, it still freezes eventually...

I am quite frustrated by this... I have no clue what cause this behaviour.  
Does anyone have ideas as to what may cause this?

The flows are uploaded in this thread where I got some help for the coding side of things:  
([The right logic for this task](https://discourse.nodered.org/t/the-right-logic-for-this-task/12404/17))

Thanks!!

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 October 2019 12:53 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/2 "2019-10-06T12:53:16Z")

</div>

Is it just the dashboard that won't load or will the editor not load either?  
When it freezes what do you see if you run  
`node-red-log`  
How do you recover?  
How did you install node-red?  
Run

```auto
node-red-start
node-red-stop

```

and copy/paste the results here, that will tell us what versions of tools you are using.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [6 October 2019 20:53 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/3 "2019-10-06T20:53:03Z")

</div>

What brand and size of SD card do you use?  
what does `df -h` show

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [7 October 2019 15:19 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/4 "2019-10-07T15:19:19Z")

</div>

I'll get back to you with info from the Pi.  
The dashboard loads, but is veeeeery slow or unresponsive.  
Loads better on my laptop than on my phone..  
Editor loads, and are less unresponsive

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [7 October 2019 15:23 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/5 "2019-10-07T15:23:42Z")

</div>

And the code that I'm running seems to be working and running in the background...

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [7 October 2019 15:32 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/6 "2019-10-07T15:32:11Z")

</div>

> [@zenofmud](#):
>
> ...what size of SD card do you use?  
> what does `df -h` show

That would be my first check too. Running out of disk space seems quite common, especially when there is an issue somewhere and the associated log files starts gobbling up SD card storage.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 October 2019 15:48 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/7 "2019-10-07T15:48:27Z")

</div>

Have you got any charts running in the dashboard? If so then what time period or number of points are they configured for (that is in the chart config), and at what rate are they being given data? Also how many lines are there on the chart(s)?

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [7 October 2019 18:37 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/8 "2019-10-07T18:37:06Z")

</div>

Sd card is 16GB

> **[16GB Micro SD - SanDisk Class 10 - Med NOOBS • RaspberryPi.dk](https://raspberrypi.dk/produkt/16gb-micro-sd-sandisk-class-10-noobs/)**
>
> Dette Micro SD-kort til Raspberry Pi er et 16GB SanDisk Class 10 UHS Micro SD-kort præinstalleret med det officielle NOOBS operativsystem. Klar til boot!
> 
> 
> Kommer med Micro SD til SD adapter.
> 
> På lager: Leveringstid 1-3 hverdage.

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [7 October 2019 18:39 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/9 "2019-10-07T18:39:48Z")

</div>

Charts are max 8hrs, and some are given input every 10secs, but most every 10min.

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [7 October 2019 18:45 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/10 "2019-10-07T18:45:35Z")

</div>

its weird since the editor works quite fine... just the dashboard that is incredibly slow or nonresponsive... 🤔

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [7 October 2019 18:47 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/11 "2019-10-07T18:47:31Z")

</div>

I have these three dashboard tabs running..

 ![06](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c93823ba4e5d3974c4afaf392355a8dad7649cc0.png) ![19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/18bd0d369a6493c369fd48e95b2c6054db28f738.png) ![32](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2a6790a0930b5cd136b3e837e18657ba7a37628a.png)

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [7 October 2019 19:03 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/12 "2019-10-07T19:03:53Z")

</div>

@FarfarGoHai what is the answer to this Jes?

> [@zenofmud](#):
>
> what does `df -h` show

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [7 October 2019 19:21 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/13 "2019-10-07T19:21:19Z")

</div>

Chart on processor card is not optimized at all. Such will harm dashboard performance for sure. Probably the other 24h chart (memory) can also have a bit less datpoints.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 October 2019 20:18 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/14 "2019-10-07T20:18:48Z")

</div>

To prove whether it is the charts add and Inject node configured to clear the charts by sending an empty array to all the charts (or separate ones for each chart if you prefer). If clicking that restores the performance then you know it is the charts.

---

<div class="post-metadata">

### Author: ![FarfarGoHai](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@FarfarGoHai](https://discourse.nodered.org/u/FarfarGoHai)
#### Post date: [12 October 2019 09:34 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/15 "2019-10-12T09:34:44Z")

</div>

```auto
ok, here goes straight from my Rpi browser.

----------------------------------------------------------
node-red-log:
12 Oct 11:24:49 - [error] [function:ah_OnOff] TypeError: Cannot read property 'payload' of undefined
12 Oct 11:24:59 - [error] [function:ah_OnOff] TypeError: Cannot read property 'payload' of undefined
---------------------------------------------------------
node-red-start:
Start Node-RED
 
Once Node-RED has started, point a browser at http://192.168.1.44:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
12 Oct 11:32:23 - [info]
Welcome to Node-RED
===================
12 Oct 11:32:23 - [info] Node-RED version: v0.20.7
12 Oct 11:32:23 - [info] Node.js version: v10.16.3
12 Oct 11:32:23 - [info] Linux 4.19.46-v7l+ arm LE
12 Oct 11:32:24 - [info] Loading palette nodes
12 Oct 11:32:26 - [info] Dashboard version 2.16.2 started at /ui
12 Oct 11:32:26 - [info] Settings file : /home/pi/.node-red/settings.js
12 Oct 11:32:26 - [info] Context store : 'default' [module=memory]
12 Oct 11:32:26 - [info] User directory : /home/pi/.node-red
12 Oct 11:32:26 - [warn] Projects disabled : editorTheme.projects.enabled=false
12 Oct 11:32:26 - [info] Flows file : /home/pi/.node-red/flows_tonsgaardRasPi.json
12 Oct 11:32:27 - [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.
---------------------------------------------------------------------
12 Oct 11:32:27 - [info] Starting flows
12 Oct 11:32:27 - [info] Started flows
12 Oct 11:32:27 - [info] Server now running at http://127.0.0.1:1880/
12 Oct 11:32:27 - [error] [function:ah_OnOff] TypeError: Cannot read property 'payload' of undefined
12 Oct 11:32:37 - [error] [function:ah_OnOff] TypeError: Cannot read property 'payload' of undefined
--------------------------------------------------------------------
df -h:
Filesystem Size Used Avail Use% Mounted on
/dev/root 13G 4.7G 7.5G 39% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 136M 1.8G 7% /dev/shm
tmpfs 2.0G 8.6M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p6 253M 40M 213M 16% /boot
tmpfs 391M 0 391M 0% /run/user/1000

does that provide any clues to people cleverer than me..

```

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [12 October 2019 10:00 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/16 "2019-10-12T10:00:33Z")

</div>

Try this, disconnect the wire to all of your graphs and deploy. Does that change anything?  
If so, add the graphs in one at a time and redeploy after each is wired up. At some point the problem should show up letting you know where the culprit is.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [12 October 2019 10:26 UTC](https://discourse.nodered.org/t/rpi-hangs-freezes-after-running-a-few-days/16381/17 "2019-10-12T10:26:15Z")

</div>

> [@FarfarGoHai](#):
>
> 12 Oct 11:32:27 - [error] [function:ah\_OnOff] TypeError: Cannot read property 'payload' of undefined

I suggest you sort that one out first.
