Home » n8n» How to update n8n Docker on VPS with Docker Compose

How to update n8n docker?

This guide shows how to update n8n docker on a Linux VPS using Docker Compose. You update n8n Docker by pulling the latest image and restarting the container with docker-compose pull and docker-compose up -d. The steps below include backup, commands, verification, and security tips for a safe upgrade.

What You Need

  • A Linux VPS with Docker and Docker Compose installed.
  • Access to the n8n docker-compose.yml or docker run command.
  • Shell access (SSH) and basic privileges to stop and start containers.
  • A recent backup of your n8n data and database.

How to update n8n docker with Docker Compose

Follow these numbered steps. Each step lists the commands to run on your VPS. Run commands as a user with Docker rights or prepend sudo.

Step 1: Backup your data

Always back up your database and persistent volumes before updating. Example for a PostgreSQL database in Docker:

docker exec -t n8n-postgres pg_dumpall -c -U postgres > ~/n8n-backup-$(date +%F).sql

Also copy any persistent volume folders. For a compose volume mounted at /home/n8n:/data:

cp -a /home/n8n /home/n8n-backup-$(date +%F)

Step 2: Pull the new image

Change to the directory with your docker-compose.yml. Use docker-compose pull to download the latest image referenced in the file.

cd /path/to/n8n
docker-compose pull n8n

If you use plain docker run, pull the image directly:

docker pull n8nio/n8n:latest

Step 3: Restart the service

Bring the updated service up. This example uses Compose to recreate only changed services with zero-downtime by using up -d.

docker-compose up -d

To ensure containers are replaced cleanly, you can also stop then start:

docker-compose down
docker-compose up -d

Step 4: Verify the upgrade

Check container status and logs. Confirm the new image and that n8n starts without errors.

docker ps --filter "name=n8n"
docker logs -f n8n

Open the n8n web UI and test a few workflows. Check credentials and webhook endpoints.

Update

Verify version inside the container if needed. Run a shell and check n8n version.

docker exec -it n8n /bin/sh -c "n8n --version"

If the upgrade fails, roll back by restoring the backup and running the previous image tag. Example:

docker-compose pull n8nio/n8n:0.277.0
docker-compose up -d

Security

  • Keep the VPS OS and Docker updated.
  • Use strong firewall rules and limit access to the n8n port.
  • Store backups off-host and test restores regularly.
  • Use environment variables for secrets and avoid hardcoding credentials in files.

Done

After verification you are finished. Your n8n Docker instance is updated and running the new image. Monitor logs for the next 24 hours to catch issues early.


Neil
Written by Neil

Neil is a true n8n geek who lives and breathes workflow automation. He dives deep into nodes, triggers, webhooks, custom logic, and self-hosting setups, sharing everything he learns about n8n on AutomationCompare.com. As part of a broader team of automation specialists, Neil focuses purely on mastering n8n and helping others unlock its full potential.

Keep Reading

Scroll to Top