# Fixing "MaxListenersExceededWarning: Possible Eventemitter memory leak detected"?

**URL:** https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335
**Category:** General
**Tags:** docker
**Created:** [6 January 2024 13:56 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335 "2024-01-06T13:56:18Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)
#### Post date: [6 January 2024 13:56 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/1 "2024-01-06T13:56:18Z")

</div>

I'm using Node-Red v3.1.3 as a docker container and just recently had to restart the container and by chance got the following entry in the logfiles:

```auto
6 Jan 14:46:39 - [info] Started flows

(node:7) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 changed listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit

(Use `node --trace-warnings ...` to show where the warning was created)

```

I don't know what "node --trace-warning" means and so far everything within Node-Red (running 12 nodes) works as expected.  
what I see on `top` on the host:

```auto
Tasks: 401 total, 1 running, 400 sleeping, 0 stopped, 0 zombie
%CPU(s): 2,9 us, 1,9 sy, 0,0 ni, 94,6 id, 0,2 wa, 0,0 hi, 0,5 si, 0,0 st
MiB Spch: 31999,4 total, 13946,1 free, 5783,6 used, 12877,6 buff/cache
MiB Swap: 976,0 total, 976,0 free, 0,0 used. 26215,8 avail Spch

    PID USER PR NI VIRT RES SHR S %CPU %MEM ZEIT+ BEFEHL
3574439 thomas 20 0 10,4g 211884 41368 S 6,3 0,6 0:49.47 node-red
...

```

Do i have to do something? And how can I find out, which node(s) cause this WARNing?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [6 January 2024 14:24 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/2 "2024-01-06T14:24:33Z")

</div>

Hi @binderth

This is a common message, and its _usually_ safe to not pay too much attention to it.  
it just means there are \> 10 subscribers to an event.

if you can advise what Node 7 is, I'm sure some friendly folk around here will have a look at the code, just to confirm that it isn't much to worry about.

---

<div class="post-metadata">

### Author: ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)
#### Post date: [6 January 2024 14:39 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/3 "2024-01-06T14:39:04Z")

</div>

> [@marcus-j-davies](#):
>
> if you can advise what Node 7 is, I'm sure some friendly folk around here will have a look at the code, just to confirm that it isn't much to worry about.

I named my nodes, so how can I find out, which one is node 7?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [6 January 2024 14:45 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/4 "2024-01-06T14:45:44Z")

</div>

Mmmm...

Can you export your flow and share it here?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 January 2024 15:38 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/5 "2024-01-06T15:38:05Z")

</div>

> [@binderth](#):
>
> I named my nodes, so how can I find out, which one is node 7

That isnt a great deal of use without you telling us what kind of node that 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: [6 January 2024 16:03 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/6 "2024-01-06T16:03:37Z")

</div>

The error suggests that you have a node that you have named 7.

---

<div class="post-metadata">

### Author: ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)
#### Post date: [6 January 2024 17:04 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/7 "2024-01-06T17:04:48Z")

</div>

> [@Steve-Mcl](#):
>
> That isnt a great deal of use without you telling us what kind of node that is!

> [@Colin](#):
>
> The error suggests that you have a node that you have named 7.

I don't have a node with a "name": 7...? so I thought it was node #7, but I don't know how to count them?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [6 January 2024 17:09 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/8 "2024-01-06T17:09:41Z")

</div>

As I asked here - it will likely be the 7th Node in the export

---

<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: [6 January 2024 17:12 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/9 "2024-01-06T17:12:45Z")

</div>

The text `(node:7)` has nothing to do with Node-RED. This is a node.js warning and that is what `node` refers to in this instance.

The only clue we have is it will most likely be something you have more than 10 instances of in your flows.

What extra nodes have you got installed and using?

---

<div class="post-metadata">

### Author: ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)
#### Post date: [6 January 2024 17:18 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/10 "2024-01-06T17:18:40Z")

</div>

> [@knolleary](#):
>
> The only clue we have is it will most likely be something you have more than 10 instances of in your flows.

- ok, I have a "mqtt-broker" as global configuration node, which I use 191 times (in my older flows I sometimes use functions to split a JSON and they do all have a seperate instance of mqtt).
- and I do have a "bluelinky" node, which I use 17 times.
- "modbus" =\> 24 times
- "tibber" =\> 10 times

neither of them is in the export at 6th or 7th place (what I supect would be node #7)

---

<div class="post-metadata">

### Author: ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)
#### Post date: [6 January 2024 17:22 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/11 "2024-01-06T17:22:22Z")

</div>

So "tibber" is your guy

> [@binderth](#):
>
> Do i have to do something?

No, just a warning message  
Usually the maximum option is disabled or not set. Some developers deactivate the maximum number, others are not aware of this (the case here I think) and still others prefer to define a number to avoid any risk of a loop hidden by this deactivation...

If a node subscribes to an event there is only one listener but if you have 100 nodes...

---

<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: [6 January 2024 17:35 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/12 "2024-01-06T17:35:25Z")

</div>

> [@GogoVega](#):
>
> "tibber" is your guy

Why have you ruled out the others?

It won't be the mqtt-broker node as we have done the work to avoid that warning in our node.

I doubt it'll be the modbus node as it is widely used and I'm not aware of other reports of this.

That leaves either tibber or bluelinky.

Given there are 10 instances of the tibber node, and the warning says an 11th listener has been registered, I'd suspect the bluelinky node.

It should be harmless, but it is worth tracking down and raising an issue against the node in question to avoid this question being asked again.

---

<div class="post-metadata">

### Author: ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)
#### Post date: [6 January 2024 17:38 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/13 "2024-01-06T17:38:19Z")

</div>

Woops, I had 10 in mind, sorry

> [@knolleary](#):
>
> Why have you ruled out the others?

I had the same reasoning  
Modbus verified, not them

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [20 January 2024 17:38 UTC](https://discourse.nodered.org/t/fixing-maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected/84335/14 "2024-01-20T17:38:25Z")

</div>

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