---
title: "Deploy n8n Queue Mode + Postgres/Redis + Backups"
description: "n8n queue mode with Postgres, Redis, workers, and backups."
category: "Automation"
url: https://railway.com/deploy/n8n-queue-mode-postgresredis-backups
---

# Deploy n8n Queue Mode + Postgres/Redis + Backups

n8n queue mode with Postgres, Redis, workers, and backups.

**[Deploy n8n Queue Mode + Postgres/Redis + Backups on Railway](https://railway.com/template/n8n-queue-mode-postgresredis-backups)**

- **Creator:** leodev
- **Category:** Automation
- **Total deploys:** 2

## Template content

### postgres-backup

- **Image:** postgres:16-alpine
- **Start command:** `/bin/sh -lc 'set -eu; mkdir -p /backups; while true; do stamp="$(date -u +%Y%m%d-%H%M%S)"; file="/backups/n8n-${stamp}.sql.gz"; echo "Writing Postgres backup to ${file}"; pg_dump "$DATABASE_URL" | gzip > "$file"; find /backups -type f -name "n8n-*.sql.gz" -mtime +"${BACKUP_RETENTION_DAYS:-14}" -delete; ls -lh /backups | tail -20; echo "Next backup in 24h"; sleep 86400; done'`

### n8n-worker

- **Image:** n8nio/n8n:latest
- **Start command:** `n8n worker --concurrency=5`
- **Health check:** /healthz/readiness

### postgres

- **Image:** postgres:16-alpine

### n8n-main

- **Image:** n8nio/n8n:latest
- **Health check:** /healthz/readiness
- **Public domain:** Yes

### redis

- **Image:** redis:7-alpine
- **Start command:** `redis-server --appendonly yes --dir /data`

## Documentation

# Deploy and Host n8n Queue Mode + Postgres/Redis on Railway

Self-host n8n with a production-shaped queue-mode architecture: Postgres for durable data, Redis for queued executions, a dedicated worker, and daily Postgres backups.

## About Hosting n8n Queue Mode + Postgres/Redis on Railway

- `n8n-main`: public n8n editor/API service
- `n8n-worker`: dedicated worker service running `n8n worker --concurrency=5`
- `postgres`: private Postgres database with persistent storage
- `redis`: private Redis queue broker with append-only persistence
- `postgres-backup`: daily `pg_dump` backup service writing `.sql.gz` dumps to a Railway volume
- Generated `N8N_ENCRYPTION_KEY`, JWT secret, database password, and app secrets

## Why Deploy n8n Queue Mode + Postgres/Redis on Railway

Most one-click n8n templates are useful demos. This variant is for users who already know they want the safer self-hosted shape:

- Queue mode for worker-based production executions
- Postgres instead of SQLite
- Redis queue broker wired over private networking
- Database-backed binary data mode for queue-mode compatibility
- Backup service included from day one

## Common Use Cases

- Production-minded n8n self-hosting
- Automation workflows with worker execution
- Internal workflow automation teams
- n8n deployments that need backups from day one
- Queue-mode evaluation on Railway

## Dependencies for n8n Queue Mode + Postgres/Redis Hosting

n8n queue mode needs Postgres for durable app data and Redis for queued executions. The worker uses the same database, queue, and encryption key as the main service. The backup service needs private Postgres access and a `/backups` volume.

### Deployment Dependencies

- `DB_TYPE`: `postgresdb`
- `EXECUTIONS_MODE`: `queue`
- `QUEUE_BULL_REDIS_HOST`: private Redis host
- `N8N_ENCRYPTION_KEY`: generated credential encryption key
- `N8N_DEFAULT_BINARY_DATA_MODE`: `database`
- `DATABASE_URL`: private Postgres URL for backups

## Post-Deploy Checklist

1. Open the n8n public URL.
2. Create the first owner account.
3. Add credentials for the services your workflows use.
4. Run a test workflow and confirm worker logs receive the execution.
5. Keep `N8N_ENCRYPTION_KEY` backed up; losing it can break encrypted credentials.
6. Confirm the backup service creates a compressed dump in `/backups`.

## Support Checklist

If a deploy fails, include all service deployment IDs, whether `n8n-main` or `n8n-worker` failed first, worker readiness output, and log lines mentioning Postgres, Redis, queue mode, or encryption key.


## Similar templates

- [N8N Main + Worker](https://railway.com/deploy/n8n-main-worker) — Deploy and Host N8N with Inactive worker.
- [Evolution API with n8n](https://railway.com/deploy/evolution-api-with-n8n) — [Jul'26] WhatsApp automation platform using Evolution API, n8n & PostgreSQL
- [Postgres Backup](https://railway.com/deploy/postgres-s3-backups) — Cron-based PostgreSQL backup to bucket storage

Open this page in a browser: https://railway.com/deploy/n8n-queue-mode-postgresredis-backups
