Short answer: stop n8n on the old server, copy the .n8n folder (the n8n_data volume, which holds the encryption key) and, if you use PostgreSQL, a pg_dump of the database. Restore both on the new server with the same compose.yaml, the same .env and the same image version, test, and only then point DNS at the new IP.
The n8n backup and restore docs describe two kinds of copy, and the difference matters when you migrate:
- Full copy (
.n8nfolder + database): carries users, credentials, workflows, executions, variables and settings. This guide follows that path. - CLI export (
n8n export:workflowandexport:credentials): carries only workflows and credentials. Users, roles, execution history and variables stay behind, and the new instance asks for owner setup again. It’s useful for switching databases (SQLite to PostgreSQL, for example); the steps are in the n8n backup guide.
/home/node/.n8n/config or in the N8N_ENCRYPTION_KEY variable. A database restored with another key starts, but no credential can be read.Some links on this page are affiliate links: if you sign up through them I may earn a commission, at no extra cost to you.
Contabo Black Friday · November 23–30
VPS Plus 2: 2 vCPU, 4 GB of RAM and 75 GB NVMe
From €7.20/month (excl. VAT) with a 24-month term. It is the entry plan of Contabo’s Performance VPS line and is on sale until Monday, November 30. 4 GB is the size the calculator suggests for n8n with PostgreSQL under moderate use.
Recommended VPS
Contabo Cloud VPS 4 (4 vCPU, 8 GB of RAM and 100 GB of SSD) leaves room for n8n, PostgreSQL and a reverse proxy on one server. It starts at $5.28/month for the first 24 months (EU region, checked on November 30, 2026); other regions cost extra.
Prepare the new server
Install Docker and copy compose.yaml and .env from the old server. They carry the database connection, N8N_ENCRYPTION_KEY (if you set one), N8N_WEBHOOK_URL and the timezone. The docs list this configuration as a required part of a restore.
scp user@OLD-IP:~/n8n-compose/{compose.yaml,.env} ~/n8n-compose/
Check the n8n image tag. Use the same version the old server runs today, and update only after the migration is up. An older version doesn’t know the database migrations a newer one already applied. Check the current version with:
docker compose exec n8n n8n --version
If you haven’t sized the new server yet, the n8n RAM and CPU requirements help you pick.
Stop n8n on the old server
docker compose stop n8n
Stopping prevents two things: copying SQLite in the middle of a write, which the docs warn produces an inconsistent backup, and new executions that would miss the copy. From here on, webhooks and schedules are paused until the new server takes over.
Copy the data
The n8n volume becomes a .tgz file. The volume name has the folder name as a prefix; check with docker volume ls:
docker run --rm -v n8n-compose_n8n_data:/data -v "$PWD":/dest alpine tar czf /dest/n8n-data.tgz -C /data .
With the default database (SQLite), that file already has everything: the database, the key and any binary files saved to disk.
With PostgreSQL, also create the dump. The database container stays up; only n8n is stopped:
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > n8n.dump
If you load community nodes from a folder (N8N_CUSTOM_EXTENSIONS) or keep files in a mounted folder such as ./local-files, copy those folders too.
Move the files to the new server:
scp n8n-data.tgz n8n.dump user@NEW-IP:~/n8n-compose/
Restore on the new server
Create the volumes without starting anything and extract the copy into the n8n volume:
cd ~/n8n-compose
docker compose create
docker run --rm -v n8n-compose_n8n_data:/data -v "$PWD":/src alpine tar xzf /src/n8n-data.tgz -C /data
With PostgreSQL, start only the database and restore the dump before starting n8n. Use the same PostgreSQL major version as the old server (for example, postgres:18 on both):
docker compose up -d postgres
docker compose exec -T postgres sh -c 'pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --clean --if-exists' < n8n.dump
Now start everything and watch the log:
docker compose up -d
docker compose logs -f n8n
If you see Mismatching encryption keys, the N8N_ENCRYPTION_KEY in .env isn’t the one in the copy. The fix is in common n8n errors.
Test before switching DNS
While DNS still points at the old server, the new server’s proxy can’t get an HTTPS certificate. To test first, open an SSH tunnel to port 5678, which the compose files on this site bind to 127.0.0.1:
ssh -L 5678:127.0.0.1:5678 user@NEW-IP
Open http://localhost:5678 in the browser and check:
- You can log in with the same user and password as before.
- A credential opens without errors (a sign the key is right).
- Published workflows are still published and the execution history is there.
Point DNS at the new server
Change the subdomain’s A record to the new IP. As soon as DNS propagates, the Traefik in this site’s compose files requests the certificate on its own, as long as ports 80 and 443 are open. Since the domain didn’t change, webhook URLs stay the same and external services need no changes.
To make the switch quick, lower the record’s TTL (to 300 seconds, for example) a day before the migration.
If the domain changes, update N8N_WEBHOOK_URL in .env, recreate the container and replace the URL in every service where you pasted a webhook by hand. Triggers that register their webhook with the external service on their own pick up the new URL when you unpublish and publish the workflow again.
Shut down the old server later
Keep the old server stopped, but not deleted, for a few days. If something is missing, the data is still there. After that, cancel the old VPS and set up backups on the new one. A migration is also a good time to update n8n to the current stable version.
VPS calculator
Not sure how much RAM and CPU to plan for? Enter your executions per day, database and whether you use queue mode: the calculator estimates RAM and vCPUs and lists the plans that fit.
Frequently asked questions
What do I copy to migrate n8n?
The .n8n folder (the n8n_data volume), which holds the encryption key and, with SQLite, the whole database. With PostgreSQL, also a pg_dump of the database. Bring the compose.yaml and .env along.
Is a CLI workflow export enough to migrate?
Not for a full migration. The export carries only workflows and credentials; users, execution history and variables stay behind.
Do I need to change webhooks after migrating?
No, if the domain stays the same. If the domain changes, update N8N_WEBHOOK_URL and replace the URL in external services.
Can I run a newer n8n version on the new server?
Use the same version for the migration and update afterwards. That way, if something fails, you know the update wasn't the cause.