Why doesn't the editor work when I get out of the terminal

I’m sorry about that question of a total noob.

I’ve been developing n8n with a docker.

Now i log on to a remote server at http:://myiP:5678

But it only works if i run a command in the terminal

docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/root/.n8n n8nio/n8n

when I leave the terminal, the site no longer works. Is this how it’s supposed to work or do I do something wrong?

Welcome to the community @etato!

That probably depends what you mean with “leave the terminal”. If you mean “closing it” then yes. That is expected. Because with the terminal also all its processes get closed and so also n8n. If you mean “leave it open and simply do something else” then “no”, n8n should then keep on running.

If you want to “detach” n8n from the terminal you can add the option -d and remove the interactive flags. n8n will then keep on running even if you close the terminal. So something like this:

docker run --rm -d  --name n8n -p 5678:5678 -v ~/.n8n:/root/.n8n n8nio/n8n

If you then want to stop n8n at a later point you can do:

docker stop n8n
2 Likes

Really thanks for fast answer

I don’t know if I understand correctly. If n8n finishes the editor, will the workflows I create still work ?

Not sure what you mean with “n8n finishes the editor”. If you close only the editor in the web-browser then everything will still work fine. If you however close n8n itself (like what you did with closing the terminal) then nothing will work anymore.

1 Like

Thanks for the answer. It really helps.

Is there any additional documentation/tutorial because the website is realtively poor?

So, maybe a little context around how executables run under Linux would help make this clearer because process execution can be very confusing.

When a program is run under Linux, this is called a process. You can think of it like a machine that someone does something to get it to perform a function. These processes (like the machine) need a user (or another process which was initially started by a user) to start them.

When a user is logged into the system interactively (usually via a GUI, command line, or SSH), the process will generally continue to run until one of four things happens:

  1. The process finishes what it was supposed to do
  2. The process experiences an error and crashes
  3. The user kills the process
  4. The session closes either by the user or the system

At this point, the process is no longer running and what it was doing has stopped. So, in the case of n8n, when the docker process is no longer running because the session has closed, n8n is no longer available.

Earlier, I mentioned that the process will generally run until one of four things happens. There is an exception to this and it occurs when an application is run in the background or detached from a user session. This way, when the session is closed, the application will still be available, assuming that it either has a different way of interacting with a user (i.e. the n8n web interface) or does not require user interaction (e.g. an automated backup program). These type of processes are sometimes referred to as services or daemons.

There are several ways to keep these processes running in the background after you have closed the terminal. You may wish to give this article a read or my earlier post about running n8n as a service using PM2.

Hopefully that helps with a bit of understanding what is going on behind the scenes.

3 Likes