Graceful shutdown code not always running

Describe the issue/error/question

The graceful shutdown code at n8n/start.ts at master · n8n-io/n8n · GitHub

	static async stopProcess() {`Stopping n8n...`);

does not always run for me - no “Stopping n8n…” appears in the logs

What is the error message (if any)?

Stopping all processes with SIGTERM

Process exited with status 143

 sock=backend at=error code=H18 desc="Server Request Interrupted" method=GET path="/rest/push?sessionId=7irkszsrm9x" status=503 bytes= protocol=http

Information on your n8n setup

  • n8n version: 0.187.2
  • Database you’re using: Postgres
  • Running n8n with the execution process: own(default)
  • Running n8n via: Docker

I have resolved this myself :slight_smile:

n8n was not receiving the SIGTERM signal from the Docker container

1 Like

Glad to hear you sorted it out, thx so much for confirming!

Thanks @MutedJam

For reference, a couple of common gotchas for when Docker is not sending signals to the containerised application (n8n) in case useful to anyone else:

1 Not using the correct ENTRYPOINT / CMD instruction form in the Dockerfile.
There are two ways of writing this. The “shell” form e.g. ENTRYPOINT command param1 param2 and the “exec” form e.g. ENTRYPOINT ["executable", "param1", "param2"]. In short you need to use the “exec” form because the “shell” form is executed with /bin/sh -c which will not pass signals to the application (see Dockerfile reference | Docker Documentation)

2 Not calling a shell script correctly in the ENTRYPOINT / CMD instruction. If you are using a shell script to run the application just by calling it e.g.


this will run in a new process and you wont receive signals from Docker.
In this situation you can use exec to run in the same process / replace the shell

exec n8n