Memory Creep on n8n self hosted 4gb VPS

Why does n8n’s memory usage increase with time on my VPS when it’s only running several workflows?

I have to keep manually restarting the server to release the memory

How do I get n8n to release the memory after each execution?

  • n8n version: 1.0.5
  • **Operating system:Centos7

Hey @Kihap69,

The memory should creep up a bit but then it will sort itself out and level out. Once an execution has finished the memory will automatically be released so there shouldn’t be an issue there, I would however recommend upgrading to 1.1 which has some fixes in it and keep an eye out for the next couple of releases which may include performance tweaks.

Hey @Jon

It doesn’t appear to be releasing any at all…Just creeps all the way to pending doom, see below… :slight_smile:

After restart…

and the cycle continues

Any advice?

Hey @Kihap69,

Looking at my own docker install it does free up the memory but I would recommend upgrading and starting from there.

How do you currently have n8n installed as well is it with npm / docker and you are using the default database or something else?

With your stats are those for the n8n process itself or the server itself? If n8n was not freeing up the memory correctly which would be a massive issue you could just restart n8n to free it up rather than the server.

I didn’t set the server up, but it was installed using the instructions from How to install N8N and setup SSL | Step by step installation guide - YouTube which I believe uses docker after watching the video myself. I presume it also uses the default database.

The stats were the server itself

I will try the update but won’t hold my breath as this seems a pretty fundamental issue, maybe not n8n though lets hope.

Hey @Kihap69,

I would imagine if it was an n8n issue we would have a lot of reports of this by now, It might be worth monitoring the n8n application itself though as it could be that there is something else on the server causing an issue.

As a test, I took a reading of the current total memory usage of the server before restarting the n8n service alone. Total had crept to 31.4% before and after restarting the n8n service dropped to 13.6 - what would that suggest?

What was n8n doing at the time? Can you also try to monitor the memory for n8n itself which will be more useful while testing :slight_smile:

I have done some checks on the memory usage for n8n cloud instances and I am not able to see this same issue there so at the moment this appears to be local to your environment so it would be handy to know more.

n8n is the only utilisation on the VPS, Jon. It was processing 10 workflows at the time.

I do not know how to monitor the memory usage for n8n itself.

Does this help…

2542 1000 13.2 7.0 296060 ? Rl+ 00:01:48 node /usr/local/bin/n8n
679 root 0.0 1.8 76836 ? Ssl 00:00:01 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
396 root 0.0 1.0 44724 ? Ssl 00:00:07 /usr/bin/containerd
395 root 0.0 0.4 20884 ? Ssl 00:00:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
115 root 0.0 0.3 13712 ? Ss 00:00:00 /lib/systemd/systemd-journald
166 systemd+ 0.0 0.3 12584 ? Ss 00:00:00 /lib/systemd/systemd-resolved
1 root 0.0 0.2 10708 ? Ss 00:00:00 init -z
2499 root 0.0 0.2 9820 ? Sl 00:00:00 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 298e800241e392f6cac860284087d79df2d92078ed9e60917fe268aaab56445d -address /run/containerd/containerd.sock
176 root 0.0 0.1 4588 ? Ss 00:00:00 /lib/systemd/systemd-udevd
193 systemd+ 0.0 0.1 6660 ? Ss 00:00:00 /lib/systemd/systemd-networkd

Hey @Kihap69,

What are the 10 workflows doing? We have a metrics endpoint you can use to monitor n8n Monitoring | n8n Docs

Thanks, I have asked my team member to enable the metrics endpoints and will revert on this later.

1 Like

Would nginx help with this at all?

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