Skip to content
SelfHostBR, home page
Guide

How to update n8n on Docker without losing data

Update self-hosted n8n on Docker Compose: back up first, pick the right tag, let the database migrations run, check the version and know how to roll back.

MMarlon Published on · updated 5 min read
On this page

Short answer: back up, pull the new image with docker compose pull, and recreate the container with docker compose up -d. n8n runs the database migrations by itself on startup. The whole process takes a minute or two.

n8n releases a new version almost every week, and several fix security issues. Before you decide whether to update right now, check the minimum safe n8n version today, the latest stable version and the n8n release notes.

Check the current version

In the folder with your compose.yaml, check and record the current version. You’ll need it if you have to roll back:

docker compose exec n8n n8n --version

Back up first

Updates change the database schema. If something goes wrong, the safe way back is restoring the backup.

  • With SQLite (default): copy the n8n data volume, which holds the database and the encryption key.
  • With PostgreSQL: make a dump with pg_dump.

The commands are in the n8n backup guide.

Pick the right tag

In production, use n8nio/n8n:stable, not latest, which can point to a beta release. If you prefer to pin an exact version, choose the latest stable release listed on the minimum safe version page. Use this configuration in compose.yaml to set the tag with a variable:

  n8n:
    image: n8nio/n8n:${N8N_VERSION:-stable}

To pin your chosen release, set N8N_VERSION in the .env file next to compose.yaml, using just the version number. This makes pull and up in step 4 use the same tag. Leave the variable unset to use stable.

Update

docker compose pull n8n
docker compose up -d

pull downloads the new image (about 270 MB compressed, 1.1 GB once extracted) and up -d recreates only the container that changed. On startup, the log shows the migrations:

docker compose logs n8n --since 2m
Migrations in progress, please do NOT stop the process.
Starting migration ...
Finished migration ...

Do not interrupt the container during migrations. Afterwards, check the version and test an important webhook or workflow:

docker compose exec n8n n8n --version

Published workflows stay active after the update; you don’t need to publish them again.

Clean up old images

Each old version keeps taking about 1 GB of disk. Once you have confirmed everything works:

docker image prune

How to roll back to the previous version

Switching the tag back to the old version sometimes works between close versions, but it is not guaranteed: the old version does not know the migrations the new one applied. The safe route is to stop n8n, restore the backup from step 2 and start with the version you recorded in step 1. If you used N8N_VERSION, set it to that number in .env before starting again. That is why the backup comes first.

Configuration warnings in the log

Recent versions list in the log variables whose default is about to change, such as N8N_RUNNERS_MODE or N8N_RUNNERS_TASK_TIMEOUT. They don’t stop n8n from starting, but read the list: if you rely on the current behavior, set the variable explicitly in compose.yaml before a future version changes the default.

If you installed n8n by following the Docker Compose guide, these steps apply exactly as written.

Frequently asked questions

How do I update n8n on Docker Compose?

Back up, run docker compose pull n8n and then docker compose up -d. n8n applies the database migrations by itself on startup.

Will I lose my workflows when I update n8n?

No: workflows, credentials and executions live in the database and the volume, which are kept. Published workflows stay active. Still, back up first, because migrations change the database.

Can I roll back to the previous n8n version?

It sometimes works between close versions, but it is not guaranteed, because the old version does not know the new migrations. The safe route is restoring the backup you took before updating.

Should I use the latest or the stable tag?

Use stable or a pinned version. The latest tag can point to a beta release.

M

Written by

Marlon

I like automation and write here what I learn building automations with n8n. Spotted a mistake or an outdated detail? Let me know.

Keep reading