Hosting n8n: queue mode, encryption keys, backups and rollback
Compare managed and self-hosted n8n and plan TLS, queue mode, persistent data, encryption keys, backups and rollback.
By Invicly Tech, , in n8n, AI Automation and Voice Agents. About 9 minutes to read.
In short
You can use n8n Cloud, where n8n runs it for you, or self-host it and own updates, backups and security. Self-hosting for production usually means PostgreSQL, a proxy that handles TLS, queue mode with Redis and workers, and an encryption key you protect. Every release needs a backup and a rollback plan.
Think of it like this: Cloud is renting a flat where the landlord fixes the boiler. Self-hosting is owning the house: more control, and you carry the keys and the repairs.
Explained simply
You can get n8n in two ways. With n8n Cloud, n8n runs it for you. With self-hosting, you run it on your own server, usually with Docker. Cloud is quicker to start. Self-hosting gives you more control over where data lives, and more work.
A small self-hosted setup is one n8n container and a database. For real use you will want PostgreSQL, because it is sturdier than the default file database. You put a reverse proxy in front to handle HTTPS, so webhooks arrive over a secure connection with the right public address.
When load grows, you can use queue mode. One main instance takes triggers and puts jobs on a queue in Redis. Separate workers run them. You can add workers as needed. All of them must use the same database and the same encryption key.
That key matters most. n8n uses it to encrypt the credentials you store. If you lose it, your backups of credentials become unreadable. So keep it in a safe place away from the database backup, pin your n8n version, back up before every upgrade and write down how to go back.
Press Play on a diagram to walk through it one step at a time.
- 1Reverse proxy
Terminates TLS and forwards to n8n
- 2n8n main
Editor, API and trigger handling
- 3Redis
Queue between main and workers
- 4n8n workers
Run the executions
- 5PostgreSQL
Workflows, credentials and execution data
- n8n runs and updates it
- Paid plans
- Less control over the host
- Fast to start
- You run Docker, database and proxy
- Licence and edition rules apply
- Full control of data location
- You own backups and security
- 1Back up
Database now, key stored apart
- 2Upgrade
Change the pinned version
- 3Smoke test
One webhook, one schedule
- 4Watch
Errors and queue age for a day
- Back to step 1
In depth
Cloud or self-hosted
n8n Cloud removes the work of servers, updates and backups, and is paid, with plans that change over time. Self-hosting needs a server, Docker or similar, and someone who owns security patches, backups and monitoring. Some features and limits depend on the edition and licence, so check the current docs and pricing pages before you commit. If you only want to learn, run n8n locally with Docker Compose for free and use fake data.
- Small team, no ops skills
- You want fast setup
- Standard data location is fine
- You must control data location
- You have someone to run it
- You need custom networking
TLS and the proxy
Put a reverse proxy such as Caddy, Nginx or Traefik in front of n8n. It holds the certificate and passes traffic to n8n. Tell n8n its public address so the webhook URLs it shows are correct, and make sure the proxy forwards the original host and protocol headers. WebSocket support in the proxy is needed for the editor. Test by opening a webhook URL from outside and checking that it uses https.
- Certificate on the proxy, not inside n8n
- Set the public webhook URL and host settings
- Allow WebSocket upgrade
- Do not expose the database or Redis to the internet
Queue mode essentials
Queue mode needs PostgreSQL and Redis. Set the execution mode to queue on the main instance and on every worker. Point all of them at the same Redis and database. Start workers with the n8n worker command, and optionally webhook processors for heavy webhook traffic. Give each worker the same encryption key. Workers show up healthy only if they can reach Redis and the database, so test with a simple workflow and look at which worker ran it.
- Main to Redis: Add job for a webhook run1Add job for a webhook run
- Worker to Redis: Pick up the job2Pick up the job
- 3Run the workflowWorker to Worker: Run the workflow
- Worker to Main: Save results to the database4Save results to the database
Backup, upgrade and rollback
Back up PostgreSQL on a schedule and before every upgrade. Keep the encryption key and your environment file in a secrets store, not in the same place as the backup. Pin the n8n image to a specific version and read the release notes before changing it. To upgrade: back up, change the version, start, run a smoke test. To roll back: stop, restore the database from the backup taken just before, set the old version and start. Rolling back only the image can fail if the new version changed the database.
- Test a restore on a spare copy, not only the backup
- Export workflows to Git as well
- Smoke test with one webhook and one scheduled run
- Write the rollback steps before you need them
Learn it in 5 short steps
About 40m each. Track them with a timer in your plan.
- 1Compare n8n Cloud and self-hosting~40m
- 2Terminate TLS behind a proxy~40m
- 3Enable queue mode with workers~40m
- 4Protect the encryption key~40m
- 5Back up and roll back a release~40m
Key points
- Queue mode needs PostgreSQL and Redis. SQLite is not supported for it.
- Set EXECUTIONS_MODE=queue on the main instance and every worker, and give workers the same N8N_ENCRYPTION_KEY.
- Without the encryption key, saved credentials in a backup cannot be read. Store the key apart from the database backup.
- Behind a proxy, use HTTPS and set the public URL so webhook addresses are correct.
- Before an upgrade, back up the database and note the current image version so you can roll back.
Key terms
Tap a card to flip it. 0/5 known
Examples
A local, pinned Docker Compose sketch
Prerequisites: Docker and Docker Compose on a test machine; no production data. Steps: pin an n8n version you have chosen, add PostgreSQL, set a key from your secrets store. Evidence: the editor opens and a test webhook returns a response. Cleanup: docker compose down -v removes containers and volumes. Check the official Docker Compose guide for the current file.
services:
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
n8n:
image: docker.n8n.io/n8nio/n8n:<pinned-version>
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: db
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
ports: ["5678:5678"]A release and rollback checklist
Scenario: Contoso Clinic upgrades n8n on a Friday morning, not Friday night. Steps follow the list. Evidence: the smoke test passes and error counts stay flat. If the smoke test fails, follow the rollback lines. Always rehearse the restore once on a spare database.
1. Announce a short maintenance window.
2. pg_dump the database to a dated file.
3. Confirm the encryption key is stored apart.
4. Change the image tag to the new pinned version.
5. Start; run one webhook and one schedule test.
Rollback: stop n8n, restore the dump, set the old tag, start.Quick reference
- Cloud: n8n runs it. Self-hosted: you own updates, backups, security.
- Production self-hosting: PostgreSQL, a TLS proxy, pinned image version.
- Queue mode needs PostgreSQL and Redis; SQLite is not supported for it.
- Set EXECUTIONS_MODE=queue on main and every worker.
- Same N8N_ENCRYPTION_KEY everywhere; store it apart from backups.
- Back up before each upgrade; test a restore at least once.
Common mistakes
- Losing the encryption key. A database backup alone cannot restore working credentials.
- Using the latest image tag in production, so a restart silently upgrades n8n. Pin a version.
- Rolling back the application but not the database, after a migration has already changed the schema.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
List three things you own when you self-host that you do not own on n8n Cloud.
- Exercise 2medium
Write the environment variables a queue-mode worker needs, using placeholders.
- Exercise 3hard
Write a rollback plan for a failed upgrade that includes the database, the image tag and a check that credentials still work.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is self-hosting n8n free?
- You can run it yourself, but licence terms depend on the edition and use, and you pay for servers and time. Read the current licence and pricing pages.
- Do I need queue mode?
- Not for small setups. Consider it when one instance cannot keep up or you need to scale executions across workers.
- Where do I keep the encryption key?
- In a secrets store or password manager, separate from database backups.