# Debian OS "nodered.service: Main process exited, code=killed, status=5/TRAP"

**URL:** https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714
**Category:** General
**Created:** [27 July 2022 17:25 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714 "2022-07-27T17:25:54Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [27 July 2022 17:25 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/1 "2022-07-27T17:25:55Z")

</div>

Hey all,

This is the first time I am using Node-RED on [Raspberry PI OS that has been installed into a PC](https://www.raspberrypi.com/software/raspberry-pi-desktop/). I didn't know this was even possible until recently, but the install was a success and now I'm trying to get my node-RED application working.

A fresh node-RED installation, however, has produced new issues I have not seen on Raspberry Pi before.

I used the bash script to install Node-RED on a brand-new install of Raspberry Pi OS on a PC. That seemed to work without errors.

However, when I start node red locally, Node-RED cannot be reached in the browser and I get the following in node-red-log:

```auto
# Fatal javascript OOM in GC during deserialization
#
nodered.service: Main process exited, code=killed, status=5/TRAP
nodered.service: Failed with result 'signal'.
nodered.service: Scheduled restart job, restart counter is at 9.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
<--- Last few GCs --->
<--- JS stacktrace --->

```

What I have tried that has not worked:

1. Running the bash script again to uninstall/reinstall
2. Remove the raspberry-pi specific nodes (since I'm not physically on a raspberry pi)

What I have tried that _does_ apparently work:

```auto
node-red-pi --max-old-space-size=256

```

My questions:

1. Is there a way to run with this setting by default? For my application, I have to auto-start node-red as a service on reboot. When I enable node-red as an autostart service, it starts in such a way that I get the above errors.

2. Does anyone have any idea what the underlying issue could be, since the fatal error on startup does not usually happen on my other node-red applications?

Thanks!

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [27 July 2022 18:01 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/2 "2022-07-27T18:01:35Z")

</div>

What hardware are you actually running on ?  
Which version of nodejs ended up being installed ? `node -v`  
What does the command `uname -m` report ?  
What does the command `getconf LONG_BIT` report ?  
What does the command `cat /proc/meminfo | grep MemTotal` report ?

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [27 July 2022 18:41 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/3 "2022-07-27T18:41:34Z")

</div>

> What hardware are you actually running on ?

Intel Core i3-8145UE  
Memory 8 GB DDR4 SO-DIMM  
Storage 256 GB mSATA SSD

> Which version of nodejs ended up being installed ? `node -v`

v16.16.0

> What does the command `uname -m` report ?

x86\_64

> What does the command `getconf LONG_BIT` report ?

32

> What does the command `cat /proc/meminfo | grep MemTotal` report ?

MemTotal: 8004592 kB

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: [27 July 2022 20:46 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/4 "2022-07-27T20:46:12Z")

</div>

What do you see if you run just  
`node-red`  
Post the full output please.

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [27 July 2022 20:54 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/5 "2022-07-27T20:54:13Z")

</div>

Interestingly that works. I thought it was only `node-red-pi --max-old-space-size=256` that was working, but `node-red` works too.

```auto
27 Jul 13:50:00 - [info] Node-RED version: v3.0.1
27 Jul 13:50:00 - [info] Node.js version: v16.16.0
27 Jul 13:50:00 - [info] Linux 5.10.0-15-amd64 ia32 LE
27 Jul 13:50:01 - [info] Loading palette nodes
27 Jul 13:50:01 - [info] Settings file : /home/pi/.node-red/settings.js
27 Jul 13:50:01 - [info] Context store : 'default' [module=memory]
27 Jul 13:50:01 - [info] User directory : /home/pi/.node-red
27 Jul 13:50:01 - [warn] Projects disabled : editorTheme.projects.enabled=false
27 Jul 13:50:01 - [info] Flows file : /home/pi/.node-red/flows.json
27 Jul 13:50:01 - [warn] Encrypted credentials not found
27 Jul 13:50:01 - [info] Server now running at http://127.0.0.1:1880/
27 Jul 13:50:01 - [info] Starting flows
27 Jul 13:50:01 - [info] Started flows

```

So, it's only `node-red-start` or starting node as a service using `sudo systemctl enable nodered.service` that is creating errors.

---

<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: [27 July 2022 20:57 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/6 "2022-07-27T20:57:03Z")

</div>

> [@raspberry](#):
>
> it's only `node-red-start` or starting node as a service using `sudo systemctl enable nodered.service` that is creating errors.

Post the contents of /lib/systemd/system/nodered.service please.  
Also the full output from `node-red-start`

---

<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: [27 July 2022 21:01 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/7 "2022-07-27T21:01:43Z")

</div>

Sorry, I keep thinking of other potentially useful stuff:  
And the full output from `node-red-pi`

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [27 July 2022 21:31 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/8 "2022-07-27T21:31:04Z")

</div>

> And the full output from `node-red-pi`

I have been playing around with uninstalling/reinstalling. The Node.js version is 14 as of this moment but the error and behavior is the same.

```auto
27 Jul 14:30:14 - [info]

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

27 Jul 14:30:14 - [info] Node-RED version: v3.0.1
27 Jul 14:30:14 - [info] Node.js version: v14.20.0
27 Jul 14:30:14 - [info] Linux 5.10.0-15-amd64 ia32 LE
27 Jul 14:30:14 - [info] Loading palette nodes
27 Jul 14:30:15 - [info] Settings file : /home/pi/.node-red/settings.js
27 Jul 14:30:15 - [info] Context store : 'default' [module=memory]
27 Jul 14:30:15 - [info] User directory : /home/pi/.node-red
27 Jul 14:30:15 - [warn] Projects disabled : editorTheme.projects.enabled=false
27 Jul 14:30:15 - [info] Flows file : /home/pi/.node-red/flows.json
27 Jul 14:30:15 - [info] Creating new flow file
27 Jul 14:30:15 - [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 Jul 14:30:15 - [warn] Encrypted credentials not found
27 Jul 14:30:15 - [info] Server now running at http://127.0.0.1:1880/
27 Jul 14:30:15 - [info] Starting flows
27 Jul 14:30:15 - [info] Started flows

```

---

<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: [27 July 2022 22:50 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/9 "2022-07-27T22:50:40Z")

</div>

Do you have two copies of node-red installed? In the first log node.js is version 16.16.0 while the second log shows node.js version 14.20.0

Something seems amiss.

UPDATE: ahhh, I see you are reinstalling so never mind.

---

<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: [28 July 2022 07:05 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/10 "2022-07-28T07:05:40Z")

</div>

Don't forget to post the contents of /lib/systemd/system/nodered.service and the full output from node-red-start. as previously asked.

Also please what you get from  
`sudo systemctl status nodered`

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [28 July 2022 16:58 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/11 "2022-07-28T16:58:06Z")

</div>

Hey Colin,

Output from `node-red-start`:

```auto

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.10.114: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.
<--- Last few GCs --->
[2705:0xd5e5290] 85 ms: Mark-sweep 1.3 (3.8) -> 1.3 (3.8) MB, 1.3 / 0.0 ms (average mu = 0.684, current mu = 0.187) allocation failure GC in old space requested
[2705:0xd5e5290] 87 ms: Mark-sweep (reduce) 1.3 (3.8) -> 1.3 (3.8) MB, 1.3 / 0.0 ms (average mu = 0.567, current mu = 0.235) last resort GC in old space requested
[2705:0xd5e5290] 89 ms: Mark-sweep (reduce) 1.3 (2.8) -> 1.3 (3.8) MB, 1.7 / 0.0 ms (average mu = 0.376, current mu = 0.005) last resort GC in old space requested
<--- JS stacktrace --->
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x8608ce1 node::Abort() [node]
 2: 0x86091ec node::OnFatalError(char const*, char const*) [node]
 3: 0x8796e28 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0x87971cd v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0x8964f19 [node]
 6: 0x897660e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 7: 0x894a0e3 v8::internal::HeapObject v8::internal::Heap::AllocateRawWith<(v8::internal::Heap::AllocationRetryMode)1>(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0x894b732 v8::internal::Factory::CodeBuilder::BuildInternal(bool) [node]
 9: 0x894bae8 v8::internal::Factory::CodeBuilder::Build() [node]
10: 0x8f45b7e v8::internal::RegExpMacroAssemblerIA32::GetCode(v8::internal::Handle<v8::internal::String>) [node]
11: 0x8c45134 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [node]
12: 0x8c65419 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int) [node]
13: 0x8c65c99 v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [node]
14: 0x8c667d7 v8::internal::RegExp::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [node]
15: 0x8c66868 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
16: 0x8c6837b v8::internal::RegExp::Exec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
17: 0x8cbfee8 v8::internal::Runtime_RegExpExec(int, unsigned int*, v8::internal::Isolate*) [node]
18: 0x901fb77 [node]
19: 0x90682c2 [node]
20: 0x8fc3219 [node]
21: 0x8fbdd72 [node]
22: 0x8fc3219 [node]
23: 0x8fbdd72 [node]
24: 0x8fc3219 [node]
25: 0x8fc3219 [node]
26: 0x8fc3219 [node]
27: 0x8fc3219 [node]
28: 0x8fc3219 [node]
29: 0x8fc3219 [node]
30: 0x8fc3219 [node]
31: 0x8fc3219 [node]
32: 0x8fc3219 [node]
33: 0x8fc3219 [node]
34: 0x8fc139a [node]
35: 0x8fc11bb [node]
36: 0x88f2dab [node]
37: 0x88f3536 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [node]
38: 0x87a85f2 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [node]
39: 0x85c8a29 node::ExecuteBootstrapper(node::Environment*, char const*, std::vector<v8::Local<v8::String>, std::allocator<v8::Local<v8::String> > >*, std::vector<v8::Local<v8::Value>, std::allocator<v8::Local<v8::Value> > >*) [node]
40: 0x85c8d18 [node]
41: 0x85ca0c2 node::StartExecution(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [node]
42: 0x855e05d node::LoadEnvironment(node::Environment*) [node]
43: 0x864be4e node::NodeMainInstance::Run() [node]
44: 0x85cc51e node::Start(int, char**) [node]
45: 0x85576ba main [node]
46: 0xf79f9e46 __libc_start_main [/lib/i386-linux-gnu/libc.so.6]
nodered.service: Main process exited, code=killed, status=6/ABRT
nodered.service: Failed with result 'signal'.

```

/  
/  
/  
/  
/  
/  
`/lib/systemd/system/nodered.service`:

```auto
# systemd service file to start Node-RED

[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html

[Service]
Type=simple
# Run as normal pi user - change to the user name you wish to run Node-RED as
User=pi
Group=pi
WorkingDirectory=/home/pi

Environment="NODE_OPTIONS=--max_old_space_size=4096"
# define an optional environment file in Node-RED's user directory to set custom variables externally
EnvironmentFile=-/home/pi/.node-red/environment
# uncomment and edit next line if you need an http proxy
#Environment="HTTP_PROXY=my.httpproxy.server.address"
# uncomment the next line for a more verbose log output
#Environment="NODE_RED_OPTIONS=-v"
# uncomment next line if you need to wait for time sync before starting
#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"'

ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# Use SIGINT to stop
KillSignal=SIGINT
# Auto restart on crash
Restart=on-failure
RestartSec=20
# Tag things in the log
SyslogIdentifier=Node-RED
#StandardOutput=syslog

[Install]
WantedBy=multi-user.target

```

Thanks!

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [28 July 2022 16:59 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/12 "2022-07-28T16:59:11Z")

</div>

And before I forget...

> `sudo systemctl status nodered`

```auto

● nodered.service - Node-RED graphical event wiring tool
     Loaded: loaded (/lib/systemd/system/nodered.service; disabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: signal) since Thu 2022-07-28 09:58:05 PDT; 18s ago
       Docs: http://nodered.org/docs/hardware/raspberrypi.html
    Process: 2878 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=killed, signal=ABRT)
   Main PID: 2878 (code=killed, signal=ABRT)
        CPU: 167ms

```

---

<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: [28 July 2022 18:22 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/13 "2022-07-28T18:22:32Z")

</div>

> [@raspberry](#):
>
> `/usr/bin/env node-red-pi`

Something very odd is going on, obviously.  
What about  
`node-red-pi --max_old_space_size=4096`  
and  
`/usr/bin/env node-red-pi --max_old_space_size=4096`  
I am trying to find a command line that fails, other than running it from the service file, which does fail.

Also does this give any output?  
`echo $NODE_RED_OPTIONS`

Does the file /home/pi/.node-red/environment exist? If so then what is in it?

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [28 July 2022 18:59 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/14 "2022-07-28T18:59:56Z")

</div>

> [@Colin](#):
>
> Something very odd is going on, obviously.  
> What about  
> `node-red-pi --max_old_space_size=4096`  
> and  
> `/usr/bin/env node-red-pi --max_old_space_size=4096`  
> I am trying to find a command line that fails, other than running it from the service file, which does fail.

So it looks like `node-red-pi --max_old_space_size=4096` has the same "JavaScript heap out of memory" issue:

```auto
 node-red-pi --max_old_space_size=4096

<--- Last few GCs --->

[7079:0xbf66290] 85 ms: Mark-sweep 1.3 (3.8) -> 1.3 (3.8) MB, 1.3 / 0.0 ms (average mu = 0.683, current mu = 0.204) allocation failure GC in old space requested
[7079:0xbf66290] 86 ms: Mark-sweep (reduce) 1.3 (3.8) -> 1.3 (3.8) MB, 1.4 / 0.0 ms (average mu = 0.561, current mu = 0.212) last resort GC in old space requested
[7079:0xbf66290] 88 ms: Mark-sweep (reduce) 1.3 (2.8) -> 1.3 (3.8) MB, 1.7 / 0.0 ms (average mu = 0.372, current mu = 0.005) last resort GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x8608ce1 node::Abort() [node]
 2: 0x86091ec node::OnFatalError(char const*, char const*) [node]
 3: 0x8796e28 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0x87971cd v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0x8964f19 [node]
 6: 0x897660e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 7: 0x894a0e3 v8::internal::HeapObject v8::internal::Heap::AllocateRawWith<(v8::internal::Heap::AllocationRetryMode)1>(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0x894b732 v8::internal::Factory::CodeBuilder::BuildInternal(bool) [node]
 9: 0x894bae8 v8::internal::Factory::CodeBuilder::Build() [node]
10: 0x8f45b7e v8::internal::RegExpMacroAssemblerIA32::GetCode(v8::internal::Handle<v8::internal::String>) [node]
11: 0x8c45134 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [node]
12: 0x8c65419 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int) [node]
13: 0x8c65c99 v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [node]
14: 0x8c667d7 v8::internal::RegExp::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [node]
15: 0x8c66868 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
16: 0x8c6837b v8::internal::RegExp::Exec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
17: 0x8cbfee8 v8::internal::Runtime_RegExpExec(int, unsigned int*, v8::internal::Isolate*) [node]
18: 0x901fb77 [node]
19: 0x90682c2 [node]
20: 0x8fc3219 [node]
21: 0x8fbdd72 [node]
22: 0x8fc3219 [node]
23: 0x8fbdd72 [node]
24: 0x8fc3219 [node]
25: 0x8fc3219 [node]
26: 0x8fc3219 [node]
27: 0x8fc3219 [node]
28: 0x8fc3219 [node]
29: 0x8fc3219 [node]
30: 0x8fc3219 [node]
31: 0x8fc3219 [node]
32: 0x8fc3219 [node]
33: 0x8fc3219 [node]
34: 0x8fc139a [node]
35: 0x8fc11bb [node]
36: 0x88f2dab [node]
37: 0x88f3536 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [node]
38: 0x87a85f2 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [node]
39: 0x85c8a29 node::ExecuteBootstrapper(node::Environment*, char const*, std::vector<v8::Local<v8::String>, std::allocator<v8::Local<v8::String> > >*, std::vector<v8::Local<v8::Value>, std::allocator<v8::Local<v8::Value> > >*) [node]
40: 0x85c8d18 [node]
41: 0x85ca0c2 node::StartExecution(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [node]
42: 0x855e05d node::LoadEnvironment(node::Environment*) [node]
43: 0x864be4e node::NodeMainInstance::Run() [node]
44: 0x85cc51e node::Start(int, char**) [node]
45: 0x85576ba main [node]
46: 0xf7abee46 __libc_start_main [/lib/i386-linux-gnu/libc.so.6]
Aborted

```

.  
.  
.  
.  
.  
And the same with `/usr/bin/env node-red-pi --max_old_space_size=4096`:

```auto
/usr/bin/env node-red-pi --max_old_space_size=4096

<--- Last few GCs --->

[7191:0xca28290] 82 ms: Mark-sweep 1.3 (3.8) -> 1.3 (3.8) MB, 1.4 / 0.0 ms (average mu = 0.679, current mu = 0.184) allocation failure GC in old space requested
[7191:0xca28290] 84 ms: Mark-sweep (reduce) 1.3 (3.8) -> 1.3 (3.8) MB, 1.3 / 0.0 ms (average mu = 0.558, current mu = 0.216) last resort GC in old space requested
[7191:0xca28290] 86 ms: Mark-sweep (reduce) 1.3 (2.8) -> 1.3 (3.8) MB, 1.7 / 0.0 ms (average mu = 0.370, current mu = 0.005) last resort GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x8608ce1 node::Abort() [node]
 2: 0x86091ec node::OnFatalError(char const*, char const*) [node]
 3: 0x8796e28 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0x87971cd v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0x8964f19 [node]
 6: 0x897660e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 7: 0x894a0e3 v8::internal::HeapObject v8::internal::Heap::AllocateRawWith<(v8::internal::Heap::AllocationRetryMode)1>(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0x894b732 v8::internal::Factory::CodeBuilder::BuildInternal(bool) [node]
 9: 0x894bae8 v8::internal::Factory::CodeBuilder::Build() [node]
10: 0x8f45b7e v8::internal::RegExpMacroAssemblerIA32::GetCode(v8::internal::Handle<v8::internal::String>) [node]
11: 0x8c45134 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [node]
12: 0x8c65419 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int) [node]
13: 0x8c65c99 v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [node]
14: 0x8c667d7 v8::internal::RegExp::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [node]
15: 0x8c66868 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
16: 0x8c6837b v8::internal::RegExp::Exec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
17: 0x8cbfee8 v8::internal::Runtime_RegExpExec(int, unsigned int*, v8::internal::Isolate*) [node]
18: 0x901fb77 [node]
19: 0x90682c2 [node]
20: 0x8fc3219 [node]
21: 0x8fbdd72 [node]
22: 0x8fc3219 [node]
23: 0x8fbdd72 [node]
24: 0x8fc3219 [node]
25: 0x8fc3219 [node]
26: 0x8fc3219 [node]
27: 0x8fc3219 [node]
28: 0x8fc3219 [node]
29: 0x8fc3219 [node]
30: 0x8fc3219 [node]
31: 0x8fc3219 [node]
32: 0x8fc3219 [node]
33: 0x8fc3219 [node]
34: 0x8fc139a [node]
35: 0x8fc11bb [node]
36: 0x88f2dab [node]
37: 0x88f3536 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [node]
38: 0x87a85f2 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [node]
39: 0x85c8a29 node::ExecuteBootstrapper(node::Environment*, char const*, std::vector<v8::Local<v8::String>, std::allocator<v8::Local<v8::String> > >*, std::vector<v8::Local<v8::Value>, std::allocator<v8::Local<v8::Value> > >*) [node]
40: 0x85c8d18 [node]
41: 0x85ca0c2 node::StartExecution(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [node]
42: 0x855e05d node::LoadEnvironment(node::Environment*) [node]
43: 0x864be4e node::NodeMainInstance::Run() [node]
44: 0x85cc51e node::Start(int, char**) [node]
45: 0x85576ba main [node]
46: 0xf7aaee46 __libc_start_main [/lib/i386-linux-gnu/libc.so.6]
Aborted

```

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [28 July 2022 19:02 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/15 "2022-07-28T19:02:00Z")

</div>

> [@Colin](#):
>
> Also does this give any output?  
> `echo $NODE_RED_OPTIONS`

Does not produce any output.

> [@Colin](#):
>
> Does the file /home/pi/.node-red/environment exist? If so then what is in it?

I'm not seeing an environment file in that location.

```auto
/.node-red $ ls
lib node_modules package.json settings.js

```

---

<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: [28 July 2022 19:16 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/16 "2022-07-28T19:16:44Z")

</div>

> [@raspberry](#):
>
> So it looks like `node-red-pi --max_old_space_size=4096` has the same "JavaScript heap out of memory" issue:

I think we are getting somewhere. So `node-red-pi --max_old_space_size=4096` fails with out of memory, but `node-red-pi --max_old_space_size=256` is ok. I think that may mean that in fact the process does not have as much memory as it should. But I think I need to hand over to @knolleary at this point.

To get you going I suggest you edit the service file and comment out the Environment line where it sets NODE\_OPTIONS, so that the ExecStart line runs node-red-pi without any options. Run `sudo systemctl daemon-reload`, or reboot, after editing the service file, in order to tell the system to re-read it.

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [28 July 2022 20:25 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/17 "2022-07-28T20:25:37Z")

</div>

> [@Colin](#):
>
> I think we are getting somewhere. So `node-red-pi --max_old_space_size=4096` fails with out of memory, but `node-red-pi --max_old_space_size=256` is ok. I think that may mean that in fact the process does not have as much memory as it should. But I think I need to hand over to @knolleary at this point.
> 
> To get you going I suggest you edit the service file and comment out the Environment line where it sets NODE\_OPTIONS, so that the ExecStart line runs node-red-pi without any options. Run `sudo systemctl daemon-reload`, or reboot, after editing the service file, in order to tell the system to re-read it.

Hey Colin,

Thanks for the help. The space allocation definitely seems to be at the root of it all. So far, node-red has been running fine as a service after removing `--max_old_space_size=4096` from the service file.

---

<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: [28 July 2022 20:34 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/18 "2022-07-28T20:34:36Z")

</div>

Great. Can you post a screenshot of what you see with the `top` command. I am interested in how much memory it says there is.

---

<div class="post-metadata">

### Author: ![raspberry](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@raspberry](https://discourse.nodered.org/u/raspberry)
#### Post date: [28 July 2022 21:16 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/19 "2022-07-28T21:16:11Z")

</div>

![htop](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d44f4616abbaa8199ecd54fd0ed481d51c8b63bd.png)

 ![top](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/388c9c2073291f267b5f8e03bb436b235b6619f2.png)

Since it's a new PC + OS install I'm wondering if the swap and memory isn't configured in the best possible way. OS installation on new hardware is definitely out of my wheel house. I just pushed through it with default/recommended settings until everything seemed to work.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [28 July 2022 22:23 UTC](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714/20 "2022-07-28T22:23:36Z")

</div>

Try setting the max-old-space to 2048. Ie work downwards until it works.

[Next page](https://discourse.nodered.org/t/debian-os-nodered-service-main-process-exited-code-killed-status-5-trap/65714.md?page=2)
