Docker offers the following advantages:
- Install n8n in a clean environment.
- Easier setup for your preferred database.
- Can avoid issues due to different operating systems, as Docker provides a consistent system.
Before proceeding, install Docker Desktop.
Self-hosting knowledge prerequisites
Self-hosting n8n requires technical knowledge, including:
- Setting up and configuring servers and containers
- Managing application resources and scaling
- Securing servers and applications
- Configuring n8n
n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends n8n Cloud.
Latest and Next versions
n8n releases a new minor version most weeks. The
latest version is for production use.
next is the most recent release. You should treat
next as a beta: it may be unstable. To report issues, use the forum.
From your terminal, run:
1 2 3
This command will download all required n8n images and start your container, exposed on port
5678. To save your work between container restarts, it also mounts a docker volume,
n8n_data, to persist your data locally.
You can then access n8n by opening: http://localhost:5678
Using alternate databases#
By default n8n uses SQLite to save credentials, past executions and workflows. n8n also supports PostgresDB configurable using environment variables as detailed below.
It's important to still persist data in the
/home/node/.n8n folder as it contains n8n user data and even more importantly the encryption key for credentials. It's also the name of the webhook when the n8n tunnel is used.
If no directory is found, n8n creates automatically one on startup. In this case, existing credentials saved with a different encryption key can not be used anymore.
Keep in mind
/home/node/.n8n directory even when using alternate databases is the recommended best practice, but not explicitly required. The encryption key can be provided via the
N8N_ENCRYPTION_KEY environment variable.
To use n8n with Postgres, provide the corresponding configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
docker-compose file for Postgres can be found here.
n8n deprecated MySQL and MariaDB as backend databases in version 0.227.0.
n8n recommends using PostgreSQL.
Refer to how to export and import workflows and credentials for instructions.
To use n8n with MySQL, provide the corresponding configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13
To define the timezone n8n should use, the environment variable
GENERIC_TIMEZONE can be set. This gets used by schedule based nodes such as the Cron node.
The timezone of the system can also be set separately. This controls what
some scripts and commands return like
$ date. The system timezone can be set via the environment variable
Example using the same timezone for both:
1 2 3 4 5 6 7 8 9
From your Docker Desktop, navigate to the Images tab and select Pull from the context menu to download the latest n8n image:
You can also use the command line to pull the latest, or a specific version:
1 2 3 4 5 6 7 8
Stop the container and start it again. You can also use the command line:
1 2 3 4 5 6 7 8 9 10 11
If you run n8n using a Docker Compose file, follow these steps to update n8n:
1 2 3 4 5 6 7 8
More information about Docker setup can be found in the README file of the Docker Image.
n8n with tunnel#
This is only meant for local development and testing. Do not use it in production.
To be able to use webhooks for trigger nodes of external services like GitHub, n8n has to be reachable from the web. To make that easy, n8n has a special tunnel service which redirects requests from our servers to your local n8n instance.
Start n8n with
--tunnel by running:
1 2 3 4 5 6 7 8