Step-by-step guide to migrate n8n to a new server, ensuring a smooth transfer of workflows, data, and settings for a secure, reliable setup.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
The short version: migrating n8n to a new server means moving your data folder (this contains all your workflows, credentials, and executions) and making sure the environment variables and database settings on the new server are the same as on the old one. If you copy the data folder and keep the same config, the new server will start exactly where the old one left off.
In a real production setup, n8n stores everything important in two places:
If you move both of these properly, the new server becomes an identical copy of the old one.
This process assumes you're running n8n in Docker, which is how most production setups are deployed. If you're not using Docker, the logic is the same — you still copy the data and use the same environment variables — just the commands will differ.
docker stop n8n
// Example if your data is stored at /var/n8n on old server:
scp -r user@old-server:/var/n8n /var/n8n
// Postgres example
pg_dump -U n8n n8n > n8n_dump.sql
scp n8n_dump.sql user@new-server:/tmp/
// On the new server
psql -U n8n n8n < /tmp/n8n_dump.sql
Example docker-compose with the same variables:
version: '3.8'
services:
n8n:
image: n8n:latest
ports:
- "5678:5678"
environment:
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY} // MUST be identical
- DB_TYPE=postgres
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- /var/n8n:/home/node/.n8n
docker compose up -d
Think of n8n as two pieces: the brain (database) and the personal diary (data folder). Move both together. Start n8n with the same secrets. It wakes up exactly where it left off.
If all 4 are yes, your migration will work.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.