Skip to content
About 5 min read0% read

How to install n8n with Docker (and when to use npm)

Otomatzia editorial team · Last verified

Short answer

For a local n8n Docker install, run the single-container command below and open http://127.0.0.1:45768. Use the downloadable Docker Compose file to test Postgres and persistence. Both examples were verified with n8n 2.49.7. New to the tool? Start with what n8n is.

Key facts
TopicDetail
Recommended methodDocker for most self-hosting needs (n8n docs)
Official installerSee the n8n installer documentation for the complete stack.
Image and portn8nio/n8n on port 5678 (n8n docs)
Data locationVolume mounted at /home/node/.n8n (n8n docs)
Default databaseSQLite; Postgres advised for production (n8n docs)
npmn8n 3.0 and later is not published to npm (n8n docs)
Versions when checkedStable 3.4.4, beta 3.5.3 (n8n docs)

Which Docker install method should you use?

n8n's docs recommend Docker for most self-hosting needs, because it gives a clean, isolated environment, avoids operating system and tooling incompatibilities, and makes database and environment management simpler, per the Docker install page. There are three Docker routes in the current docs, and they suit different jobs.

Before you pick one, be honest about the work. n8n's own guidance says self-hosting is for expert users and that mistakes can lead to data loss, security issues and downtime. If nobody on the team wants to run a server, our n8n Cloud vs self-hosted comparison covers the hosted option.

n8n Docker install methods compared (from the n8n docs, December 2026)
MethodBest forWhat you writeSource
One-line setupA fresh install, fastest startNothing; the script writes compose.yml and .envn8n docs
docker runA quick single container testOne docker run commandn8n docs
Docker Compose by handProduction setups that need Postgrescompose.yml, .env and a SearXNG settings filen8n docs
npm (not Docker)An existing 2.x install onlynpm install n8n -gn8n docs

Where is the official Docker installer?

n8n documents an installer that sets up a complete stack. The single-container and Postgres examples below cover a local test where the editor is available only on your computer.

How do you run n8n with a single docker run command?

The Docker install page still publishes a plain docker run command, though it now marks that page as outdated and points to Docker Compose as the recommended method. It is still the clearest way to see what n8n needs: one image, one port and one volume. Replace the timezone placeholders with a value such as Asia/Jerusalem or America/New_York.

The command creates a volume for persistent data, downloads the n8nio/n8n image, maps port 5678, sets TZ for the system clock and GENERIC_TIMEZONE for schedule nodes such as the Schedule Trigger, enforces secure permissions on the settings file, and mounts the n8n_data volume at /home/node/.n8n. The --rm flag removes the container when it stops; your data survives because it lives in the volume.

With this example, open http://127.0.0.1:45768. The /healthz route returned status ok in a loopback test.

Start n8n in one container (from the n8n Docker install docs)
bash
docker volume create n8n_data

docker run -it --rm \
 --name n8n \
 -p 127.0.0.1:45768:5678 \
 -e GENERIC_TIMEZONE="<YOUR_TIMEZONE>" \
 -e TZ="<YOUR_TIMEZONE>" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -v n8n_data:/home/node/.n8n \
 n8nio/n8n:2.49.7

How do you test n8n and Postgres with Docker Compose?

Download the loopback Compose example. It uses n8n 2.49.7 and Postgres 17, with separate Docker volumes. Set N8N_FIXTURE_PG_PASSWORD to a strong local password in your shell before starting it.

We checked that n8n created its workflow table in Postgres and returned to readiness after restarting the n8n container. For a production deployment, follow the n8n Docker Compose guide. Back up the /home/node/.n8n volume and preserve your encryption key.

  1. From the folder containing the file, run docker compose -f compose-loopback.yaml up --wait.
  2. Open http://127.0.0.1:45770/healthz/readiness and look for status ok.
  3. Stop and start n8n again with docker compose -f compose-loopback.yaml restart n8n. Check the same readiness URL once it has restarted.

When should you use npm instead of Docker?

Almost never for a new install. The npm install page says n8n 3.0 and later is not published to npm, and the n8n package there stays on the last 2.x release. The one-line setup guide adds that npm install n8n and npx n8n no longer work for new n8n 3.0 installs, and that existing npm installs keep working for now.

If you do run the 2.x package, it needs Node.js between 20.19 and 24.x, and n8n Assistant is not available with the npm method. Commands like export:workflow still work in both cases; under Docker you run them inside the container with docker exec, per the CLI docs.

Failure modes and fixes

Each row is a problem described in the n8n or Docker documentation, with the fix it gives.

Common n8n Docker problems
SymptomCauseFixSource
Workflows gone after removing the containerNo volume; a container's writable layer is deleted with itMount a volume at /home/node/.n8n, as in the docker run commandDocker docs
All data deleted after a stopdocker compose down -v removes the volumesStop with down, without -vn8n docs
Schedules fire at the wrong hourGENERIC_TIMEZONE not setSet GENERIC_TIMEZONE and TZ to your zonen8n docs
Slow start or permission errors on WindowsProject folder under /mnt/c in WSLKeep the folder inside the WSL filesystem, for example ~/n8nn8n docs
Postgres starts with an empty databasePGDATA line removed for postgres:18Keep PGDATA set to /var/lib/postgresql/datan8n docs
database files are incompatible with serverImage bumped to Postgres 18 over older dataBack up with pg_dumpall, then follow the Postgres upgrade guiden8n docs
npm installs an old versionn8n 3.0 and later is not on npmUse the one-line setup or Docker Composen8n docs

Questions about n8n and Docker

Answers from the n8n and Docker documentation.

Can you host n8n on Docker?

Yes, and it is the recommended way. n8n's docs recommend Docker for most self-hosting needs, and from n8n 3.0 n8n is only distributed through Docker, per the one-line setup guide. The single-container example above is a tested local starting point.

Is Docker just a VM?

No. Docker's docs explain that a virtual machine boots its own complete operating system, kernel included, while a container is an isolated process that shares the host's kernel. That is why a container starts in about a second. The trade-off is that a VM's isolation is stronger. On macOS and Windows, Docker Desktop runs Linux containers inside a small Linux VM it manages for you.

How do I update n8n in Docker?

With Compose, run docker compose pull, then docker compose down, then docker compose up -d in the folder with your compose file. With a single container, pull n8nio/n8n, stop and remove the old container, and start a new one, per the Docker install page. One-line installs use the --upgrade flag.

Is the n8n tunnel safe for production?

No. The Docker install page says the cloudflared tunnel is for local development and testing and is not safe to use in production.

Want n8n installed and maintained for you

If you would rather not run the server yourself, describe your setup and we will point you to a fitting provider from the n8n provider list. You can also compare other tools in our n8n alternatives guide or on the n8n profile.

Sources

Vendor features and prices change. Confirm details on the linked official pages before you rely on them.

Keep reading

More in this topic: n8n

All guides