Self-hosting n8n with Docker

n8n · Advanced · 14 min

Self-hosting gives you control over data and cost, but you become responsible for keeping n8n safe and running.

Self-hosting means running n8n on a computer you control, usually a cloud server. The recommended way is Docker: a tool that runs software in a container, a sealed package containing the program and everything it needs, so it runs the same everywhere. Docker Compose describes several containers (n8n, a database) in one file.

Key pieces:

  • Image: the official package is n8nio/n8n. Pin an exact version tag (for example 2.43.8) rather than "latest", so updates happen when you choose. In 2.x the release channels are called stable and beta.
  • Volume: a storage folder that survives container restarts. Mount one at /home/node/.n8n. It holds the encryption key that protects all credentials. Lose it, and saved credentials can't be decrypted.
  • Database: n8n uses SQLite (a single-file database) by default. For production use PostgreSQL via DB_TYPE=postgresdb and the DB_POSTGRESDB_* settings. MySQL is no longer supported for n8n's own data in 2.x.
  • Settings are environment variables (named values given to the container), such as GENERIC_TIMEZONE and TZ for schedules, and WEBHOOK_URL so webhook URLs show your public address.
  • HTTPS: put n8n behind a reverse proxy (a front server such as Caddy, Traefik or nginx that handles certificates), so logins and webhooks are encrypted.

Updating: pull the new image, then recreate the container. Read the release notes first, back up the database and the .n8n folder, and test on a copy for major versions.

You are now the operator: backups, updates, monitoring and security are your job.

Example

docker volume create n8n_data
docker run -it --rm --name n8n -p 5678:5678 \
  -e GENERIC_TIMEZONE="Europe/Berlin" -e TZ="Europe/Berlin" \
  -v n8n_data:/home/node/.n8n \
  n8nio/n8n
# then open http://localhost:5678

Remember

  • Run n8n with Docker (Compose for production) and a persistent .n8n volume
  • Back up the encryption key and the database
  • Use PostgreSQL, pin versions, and serve over HTTPS

Watch out for

  • Running without a volume, so every restart wipes workflows and the encryption key.

Check yourself

  1. Why is the /home/node/.n8n volume so important?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.n8n.io/deploy/host-n8n/install-options/install-with-docker