---
title: "Deploy n8n-workers-template"
description: "n8n queue mode: Primary+Worker+Redis+Postgres. No API keys."
category: "Automation"
url: https://railway.com/deploy/n8n-workers-template
---

# Deploy n8n-workers-template

n8n queue mode: Primary+Worker+Redis+Postgres. No API keys.

**[Deploy n8n-workers-template on Railway](https://railway.com/template/n8n-workers-template)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/n8n-workers-template/manifest.json

- **Creator:** goat-general-prod
- **Category:** Automation

## Template content

### Worker

- **Image:** n8nio/n8n
- **Start command:** `n8n worker`

### Postgres

- **Image:** postgres:16

### Redis

- **Image:** redis:7-alpine
- **Start command:** `redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir ${RAILWAY_VOLUME_MOUNT_PATH:-/data}`

### Primary

- **Source:** https://github.com/9o4t/n8n-workers
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host n8n with Workers on Railway

Advanced [n8n](https://n8n.io/) on Railway in **queue mode**: Primary (editor + webhooks) + Worker + Redis + Postgres. This is the scalable stack on [c17.io/stacks/n8n-workers](https://c17.io/stacks/n8n-workers).

For personal / light use, prefer the simpler two-service template: [9o4t/n8n](https://github.com/9o4t/n8n) → [c17.io/stacks/n8n-automation](https://c17.io/stacks/n8n-automation).

No LLM or SaaS API keys are required to boot. Railway injects `PORT`. The template generates `N8N_ENCRYPTION_KEY` (shared by Primary and Worker) and wires `WEBHOOK_URL` to the public domain.

> **Cost note:** four services (Primary, Worker, Redis, Postgres) cost more than the simple n8n + Postgres stack. Use this when concurrent workflows or heavy jobs would slow the editor.

## About Hosting n8n with Workers

Queue mode separates the UI from execution:

```text
Browser / Webhooks → Primary (n8n start)
                         ↓
                      Redis (Bull queue)
                         ↓
                      Worker (n8n worker)
                         ↓
                      Postgres
```

| Service | Source | Public | Notes |
|---|---|---|---|
| `Primary` | Docker image `n8nio/n8n` | Yes | `n8n start`. Health `GET /healthz`. Volume `/home/node/.n8n`. |
| `Worker` | Docker image `n8nio/n8n` | No | `n8n worker`. Shares DB, Redis, and encryption key. |
| `Redis` | `redis:7-alpine` (or Railway Redis) | No | Bull queue broker. |
| `Postgres` | `postgres:16` | No | Workflows, credentials, execution history. |

Both Primary and Worker need `EXECUTIONS_MODE=queue` and the **same** `N8N_ENCRYPTION_KEY`. Losing the key makes stored credentials unreadable.

The first account you create in the editor is the owner. There is no default username or password.

## Common Use Cases

- High-volume webhooks without blocking the editor
- Concurrent / heavy workflows offloaded to workers
- Scale throughput by adding Worker replicas
- Production-style automation where UI and execution stay separate

## Dependencies for n8n with workers Hosting

### Required (wired or generated — you do not type these)

| Variable | Service | Source |
|---|---|---|
| `PORT` | Primary / Worker | `5678` (Railway may also inject) |
| `EXECUTIONS_MODE` | Primary / Worker | `queue` |
| `N8N_ENCRYPTION_KEY` | Primary | Generated. Worker refs `${{Primary.N8N_ENCRYPTION_KEY}}` |
| `WEBHOOK_URL` | Primary | `https://${{RAILWAY_PUBLIC_DOMAIN}}` |
| `N8N_EDITOR_BASE_URL` | Primary | `https://${{RAILWAY_PUBLIC_DOMAIN}}` |
| `DB_TYPE` | Primary / Worker | `postgresdb` |
| `DB_POSTGRESDB_*` | Primary / Worker | Refs to Postgres |
| `QUEUE_BULL_REDIS_*` | Primary / Worker | Refs to Redis |
| `QUEUE_BULL_REDIS_DUALSTACK` | Primary / Worker | `true` (Railway private DNS is IPv6) |
| `OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS` | Primary / Worker | `true` |

### Optional

| Variable | Required | Why |
|---|---|---|
| `GENERIC_TIMEZONE` | No | Cron timezone, e.g. `America/New_York`. Default UTC. |
| Slack / OpenAI / Google keys | No | Added inside n8n credentials after deploy. BYO. |

### Volumes

| Mount | Service | Why |
|---|---|---|
| `/home/node/.n8n` | Primary | Settings, binary data. Keep even with Postgres. |
| `/var/lib/postgresql/data` | Postgres | Database files |
| `/data` | Redis | AOF / RDB persistence |

Worker is stateless by default (no volume).

## Why Deploy n8n Workers on Railway?

The simple n8n + Postgres template is cheaper and enough for most personal graphs. This workers stack costs more because Redis and a Worker run continuously — worth it when the editor would otherwise stall under load. Trial credits cover the first deploy for most people. c17 never charges you — Railway usage is the referral / template kickback.

See `TEMPLATE.md` for the marketplace / composer shape.

## Run locally

```bash
cp .env.example .env
# set POSTGRES_PASSWORD, REDIS_PASSWORD, N8N_ENCRYPTION_KEY (openssl rand -hex 32)
docker compose up
```

Editor: http://localhost:5678 — create the first owner account. Worker logs should show it consuming the queue.

## License

n8n is fair-code (Sustainable Use License). This repo is config and docs only.


## 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) — Automate WhatsApp workflows with Evolution API, n8n, and Postgres.
- [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-workers-template
