Keep n8n running after closing terminal

Hi,

how do I keep n8n running after starting with “n8n start” and closing terminal?

@LPilic welcome to the community.

You can do npm run dev & just add “&” after the command. This would work with macOS and Linux.

Thx,

that doesn’t work either:

Editor is now accessible via:
http://localhost:5678/

Press “o” to open in Browser.

Stopping n8n…
[1]+ Exit 254 npm run dev

I´m on Centos 7, created a supervisord .ini

My host is Uberspace.de. But as long as I keep Terminal open it’s running fine. Closing or exiting Terminal terminates the frontend/edito of n8n

Weird cuz it works for me but, I’m running macOS. So I doubt the issue is N8N related. @jan do you have any clue what maybe be happening here? You are better suited since you are a Linux user.

What you need is the same as for any Node.js application. You should probably check outpm2 or forever. That would however only solve the problem with the process not stopping and restarting it automatically if it crashes. Is probably best to follow the guide here and to run it with docker-compose:
https://docs.n8n.io/#/server-setup

That makes additionally also sure that you have SSL set up correctly which is manually also not that much fun.

Hi,

Thx. Unfortunately Docker is not an option. Will check out the other hint.

The GNU screen command may also be useful here. I’m running on an AWS EC2 and my n8n session is started within a screen, but put in the background. When I log on through SSH, I reattach the screen and can see what’s been happening with n8n logs. To log off, I use CTRL + A+ D and it switches back to another screen, where I log out of SSH.

I’m working on getting n8n to run with PM2 later today. I’ll post the configuration when it is ready.

2 Likes

As promised, I have created a brief tutorial on using PM2 to manage n8n as a service. Please check out Run n8n as a Service with PM2 for all the details.

3 Likes