---
title: "Deploy n8n Queue Mode with Workers — Self-Hosted Scaling"
description: "Self-hosted n8n in queue mode — workers, webhooks & Redis. Scales fast."
category: "Automation"
url: https://railway.com/deploy/n8n-queue-mode-workers
---

# Deploy n8n Queue Mode with Workers — Self-Hosted Scaling

Self-hosted n8n in queue mode — workers, webhooks & Redis. Scales fast.

**[Deploy n8n Queue Mode with Workers — Self-Hosted Scaling on Railway](https://railway.com/template/n8n-queue-mode-workers)**

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

## Template content

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2.1
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

### main

- **Image:** n8nio/n8n:2.20.9
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### worker

- **Image:** n8nio/n8n:2.20.9

## Documentation

# Deploy and Host n8n with Queue Mode Workers on Railway

![n8n workflow builder](https://user-images.githubusercontent.com/65276001/173571060-9f2f6d7b-bac0-43b6-bdb2-001da9694058.png)

n8n is the world's most popular open-source workflow automation platform — **188k+ GitHub stars**,
500+ integrations, and unlimited executions when self-hosted. This template deploys a
**production-grade, queue mode architecture**: a dedicated main instance for the UI, a separate
worker for parallel execution, a webhook processor for high-concurrency triggers, PostgreSQL for
persistence, and Redis as the job broker — all pre-configured and ready to scale from day one.

Unlike basic n8n templates that deploy a single container, this setup separates concerns so your
editor never slows down during heavy workflow execution, workers scale horizontally with a single
click, and webhooks are never blocked by running jobs.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **n8n Main** | Workflow editor and API — manages the UI, schedules triggers, and dispatches jobs to the queue on port `5678` |
| **n8n Worker** | Executes queued workflow jobs in parallel — stateless, horizontally scalable by adding replicas |
| **n8n Webhook** | Dedicated webhook processor — handles incoming HTTP triggers without blocking workflow execution |
| **PostgreSQL 17** | Persistent storage for workflows, credentials, users, and full execution history |
| **Redis** | BullMQ job broker — coordinates job distribution between main, workers, and webhook processor |

All five services are pre-wired via Railway's private network. `EXECUTIONS_MODE=queue` is set
on the main instance out of the box — no manual configuration required to activate queue mode.

---

## About Hosting n8n with Workers

A single-container n8n deployment hits a hard ceiling: the editor UI slows down during heavy
executions, webhooks queue behind running jobs, and there is no path to horizontal scaling without
restructuring the entire setup. Queue mode solves this by splitting n8n into independent layers —
but configuring it manually requires coordinating five services, shared encryption keys, Redis
queue settings, and private networking across containers.

This template handles all of it at deploy time. Every service shares the same `N8N_ENCRYPTION_KEY`
via Railway reference variables. Workers connect to the same PostgreSQL and Redis instances
automatically. The webhook processor handles incoming triggers independently so high-frequency
webhook workflows never block scheduled or manual executions.

Typical cost: **~$10–20/month** on Railway's Hobby plan for the full five-service stack. n8n
Cloud's equivalent scalable tier starts at $50/month with execution caps — self-hosting removes
the cap entirely.

---

## Deploy in Under 5 Minutes

1. Click **Deploy on Railway** — all five services build and wire automatically (~4–5 minutes)
2. Set `WEBHOOK_URL` to your Railway main service public domain in the Variables tab
3. Set `N8N_BASIC_AUTH_USER` and `N8N_BASIC_AUTH_PASSWORD` to protect the editor
4. Open your Railway URL — n8n editor loads with queue mode already active
5. Set your admin credentials on first launch and start building workflows

No SSH. No manual Redis or PostgreSQL configuration. No Docker Compose.

---

## Common Use Cases

- **High-volume workflow automation without execution caps** — run thousands of concurrent
  workflow executions by adding worker replicas; no per-execution billing, no Zapier step limits
- **AI agent and LLM pipelines at scale** — run Claude, GPT-4o, or Gemini-powered workflows in
  parallel without the editor UI becoming unresponsive during heavy AI inference calls
- **Webhook-heavy integrations** — receive high-frequency events from Stripe, GitHub, Shopify,
  or any third-party service via the dedicated webhook processor without execution backlog
- **Self-hosted Zapier alternative for teams** — queue mode enables multiple team members to
  trigger and monitor workflows simultaneously without resource contention
- **Data pipeline and ETL orchestration** — run parallel data sync, transformation, and loading
  jobs across multiple workers; scale horizontally as pipeline volume grows
- **Enterprise automation infrastructure** — the main + worker + webhook architecture matches
  n8n's recommended production topology for teams running automation at scale

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `EXECUTIONS_MODE` | ✅ Pre-set | `queue` — activates queue mode across all n8n services |
| `WEBHOOK_URL` | ✅ Required | Your Railway main service public URL — required for webhook triggers |
| `N8N_ENCRYPTION_KEY` | ✅ Auto-shared | Auto-generated 32-char key — shared across main, worker, and webhook via reference variable |
| `DB_TYPE` | ✅ Pre-set | `postgresdb` — connects all n8n services to Railway PostgreSQL |
| `DATABASE_URL` | ✅ Auto-injected | PostgreSQL connection string via Railway reference variable |
| `QUEUE_BULL_REDIS_HOST` | ✅ Auto-injected | Redis host via Railway reference variable |
| `QUEUE_BULL_REDIS_PORT` | ✅ Auto-injected | Redis port via Railway reference variable |
| `N8N_BASIC_AUTH_ACTIVE` | Recommended | Set to `true` — protects the editor from public access |
| `N8N_BASIC_AUTH_USER` | Recommended | Username for editor basic auth |
| `N8N_BASIC_AUTH_PASSWORD` | Recommended | Password for editor basic auth — use a strong value |
| `EXECUTIONS_DATA_PRUNE` | Recommended | Set to `true` — prevents PostgreSQL bloat from execution history |
| `EXECUTIONS_DATA_MAX_AGE` | Recommended | Retention window in hours — `168` keeps 7 days of history |
| `N8N_WORKERS_CONCURRENCY` | Optional | Number of parallel jobs per worker — defaults to `10` |

> To scale workers horizontally: increase the replica count on the `n8n-worker` service in
> Railway. All replicas pull from the same Redis queue automatically — no additional configuration.

---

## Dependencies for n8n Workers Hosting

- Railway account — Hobby plan (~$10–20/month) covers all five services
- Public HTTPS endpoint for webhook-triggered workflow delivery (provisioned automatically)
- Optional: Railway volume for additional file storage in Code node workflows

### Deployment Dependencies

- [n8n GitHub Repository](https://github.com/n8n-io/n8n)
- [n8n Queue Mode Documentation](https://docs.n8n.io/hosting/scaling/queue-mode/)
- [n8n Environment Variables Reference](https://docs.n8n.io/hosting/configuration/environment-variables/)
- [n8n Worker Configuration](https://docs.n8n.io/hosting/scaling/queue-mode/#worker)
- [Railway Documentation](https://docs.railway.com)

### Implementation Details

This template runs n8n in queue mode with a distributed five-service architecture. The main
instance manages the editor UI and dispatches all workflow executions — including scheduled
triggers and manual runs — to the Redis BullMQ queue. Workers poll the queue independently
and execute jobs in parallel. The webhook processor handles all incoming HTTP triggers on its
own service so high-frequency webhook workflows never compete with running executions.

`N8N_ENCRYPTION_KEY` is auto-generated at deploy time and shared across all three n8n services
via Railway reference variables — all services decrypt credentials from the same PostgreSQL
store without any manual key sharing. Services communicate over Railway's private internal
network — PostgreSQL and Redis ports are never exposed publicly.

---

## Frequently Asked Questions

**What is the difference between this and a basic n8n Railway template?**
A basic single-container n8n deployment runs the editor, scheduler, and workflow executor in the
same process. Under heavy load, the editor becomes unresponsive and webhooks queue behind running
jobs. This template separates those concerns across five services — the editor never competes
with execution, and workers scale horizontally by adding replicas.

**How do I scale this for higher workflow volumes?**
Increase the replica count on the `n8n-worker` service in Railway. All worker replicas are
stateless and pull from the same Redis queue automatically. For webhook-heavy workloads, scale
the `n8n-webhook` service replicas separately. No additional configuration required.

**How much does it cost vs n8n Cloud?**
The full five-service stack runs at approximately $10–20/month on Railway's Hobby plan with
unlimited executions. n8n Cloud Pro costs $50/month with a 10,000 execution cap. At scale,
the cost difference compounds significantly in self-hosting's favour.

**Does queue mode break anything from my existing n8n workflows?**
No. Queue mode is transparent to workflow logic — the same nodes, triggers, and integrations
work identically. The only change is that executions are dispatched through Redis rather than
running inline in the main process.

**Do I lose workflows or credentials if Railway redeploys?**
No. All workflows, credentials, execution history, and settings are stored in PostgreSQL — not
inside any container. Redeploys, worker restarts, and version updates do not affect your data.

**Can I use AI and LangChain nodes in queue mode?**
Yes — all AI nodes including Claude, GPT-4o, Gemini, Pinecone, and LangChain integrations work
fully in queue mode. Workers execute AI workflow jobs in parallel, so multiple AI-heavy workflows
run simultaneously without the editor becoming unresponsive.

---

## Why Deploy n8n Queue Mode Workers on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your
infrastructure so you don't have to deal with configuration, while allowing you to vertically
and horizontally scale it.

By deploying n8n with queue mode workers on Railway, you get a production-grade automation
infrastructure — five pre-wired services, unlimited parallel executions, horizontal worker
scaling, and zero server administration — at a fraction of n8n Cloud's per-execution pricing.

## 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-queue-mode-workers
