---
title: "Deploy n8n Queue Stack [Updated Sep'26]"
description: "Queue-mode n8n: main, worker, Redis, Postgres. All images pinned."
category: "Automation"
url: https://railway.com/deploy/n8n-queue-stack
---

# Deploy n8n Queue Stack [Updated Sep'26]

Queue-mode n8n: main, worker, Redis, Postgres. All images pinned.

**[Deploy n8n Queue Stack [Updated Sep'26] on Railway](https://railway.com/template/n8n-queue-stack)**

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

- **Creator:** SB
- **Category:** Automation
- **Total deploys:** 1

## Template content

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

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

### n8n https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/n8n.svg

- **Image:** ghcr.io/n8n-io/n8n
- **Public domain:** Yes

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

- **Image:** redis:8.2
- **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"`

### n8n-runner https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/n8n.svg

- **Image:** ghcr.io/n8n-io/runners

### n8n-worker https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/n8n.svg

- **Image:** ghcr.io/n8n-io/n8n

## Documentation

![n8n visual workflow canvas with connected nodes](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

# Deploy and Host n8n Queue Stack on Railway

n8n is a fair-code workflow automation platform and the leading self-hosted alternative to Zapier — same visual canvas, 400+ integrations, no per-task billing, no data leaving your infrastructure. Most self-hosted n8n runs as one container serving the editor, webhooks and executions alike, which holds until a single slow run freezes the UI. This template wires n8n in queue mode across four services with generated secrets and private networking configured, so you get a production execution tier on your first deploy.

## What This Template Deploys

| Service | Purpose |
| --- | --- |
| `n8n` | Editor, REST API and webhooks on port `5678`. The only public service, health-checked at `/healthz`. |
| `n8n-worker` | Same image started with `n8n worker`. Pulls jobs off the queue and executes them. Scale this one. |
| `Postgres` | Workflows, encrypted credentials, execution history. Volume at `/var/lib/postgresql/data`. |
| `Redis` | BullMQ job broker. Volume at `/data`. |

All four talk over Railway's private network, so queue and database traffic never touches the public internet. Only Postgres and Redis carry volumes — neither n8n container holds state.

## About Hosting

**The encryption key is the trap that bites everyone.** `N8N_ENCRYPTION_KEY` must be byte-identical across every n8n service. Get it wrong and nothing fails at deploy — the editor loads, workflows save, then executions fail at runtime with decryption errors that look like an API problem.

**Queue mode cannot run on SQLite.** Single-container guides call the database optional. Here it isn't — the main process and worker need a shared durable store, so Postgres is mandatory.

**Execution history grows without limit by default.** n8n keeps every run, binary payloads included, until told otherwise. A busy instance fills a volume in weeks, so set pruning early.

**Production webhooks break without an explicit public URL.** n8n builds webhook URLs from its host config. Left unset it hands out localhost addresses nothing external can reach, and the failure is silent — the workflow never fires.

**n8n is memory-bound before it is CPU-bound.** Four vCPU with 8 GB beats eight vCPU with 4 GB. Budget 512 MB–1 GB per worker and add RAM or replicas rather than cores.

**Typical cost: ~$15–25/month** at light traffic, on Railway's rates of $10/GB/month RAM, $20/vCPU/month CPU and $0.15/GB/month volumes. Cost scales with worker replicas, not workflow count.

## How It Compares

| | n8n (self-hosted) | Zapier | Make | Activepieces |
| --- | --- | --- | --- | --- |
| Self-hosting | Yes, full stack | No | No | Yes |
| Billing | Infrastructure only | Per task | Per operation | Infra or cloud |
| Integrations | 400+ | 6,000+ | 2,000+ | ~280 |
| Custom code | JavaScript, Python | Limited | Limited | TypeScript |
| Licence | Fair-code | Proprietary | Proprietary | MIT |

The honest edge: Zapier has far more integrations and you will hit services n8n has no node for. The HTTP Request node covers any REST API, but it costs an hour Zapier would have saved. That hour buys unmetered executions and credentials that never sit on someone else's server — worth it for many or long-running workflows, not a handful of simple ones.

## Deploy in Under 5 Minutes

1. Click **Deploy** and pick a workspace. Railway provisions all four services and generates the encryption key and database credentials.
2. Wait for `n8n` to pass its health check at `/healthz`. The worker may restart once while Postgres and Redis come up.
3. Open the generated Railway domain. Self-hosted n8n has **no default credentials** — the first page is the owner-account form, and whoever submits it owns the instance.
4. Build a throwaway workflow: Manual Trigger, then a Code node returning `[{ json: { ok: true } }]`. Execute it.
5. Open **Executions** and confirm the run shows as *finished* — it travelled main → Redis → worker, proving the stack is wired.

> Tip: claim the owner account yourself before sharing the domain.

![n8n editor showing a workflow and its execution result](https://europe1.discourse-cdn.com/n8n/original/3X/1/d/1d726424ed9ace1ce06d4d6fedf68bef96637149.png)

## Common Use Cases

- **AI agents and RAG assistants** — chain a chat model, a vector store and your internal APIs as tools, with prompts and embeddings never leaving your infrastructure.
- **Scheduled data movement** — cron-triggered syncs between Postgres, warehouses, spreadsheets and SaaS tools, plus nightly reports and cleanups.
- **Internal API orchestration** — one webhook that fans out to several services and returns a single normalised payload.
- **Long-running jobs** — bulk backfills and file transforms, where queue mode pays off: the run occupies a worker, not the editor.

## Configuration

| Variable | Required | Description |
| --- | --- | --- |
| `N8N_ENCRYPTION_KEY` | Yes | Encrypts stored credentials. Generated at deploy; identical on both n8n services. |
| `EXECUTIONS_MODE` | Yes | `queue`, so the main process enqueues work instead of running it. |
| `DB_TYPE` | Yes | `postgresdb`. Queue mode does not support SQLite. |
| `DB_POSTGRESDB_*`, `QUEUE_BULL_REDIS_*` | Yes | Postgres and Redis connection details, set as reference variables on private hostnames. |
| `WEBHOOK_URL` | Yes | Your public Railway domain. Without it, production webhook URLs are unreachable. |
| `EXECUTIONS_DATA_PRUNE` | No | `true` deletes old executions automatically. Recommended. |
| `GENERIC_TIMEZONE` | No | Timezone for cron triggers. Defaults to UTC. |

> **Never rotate `N8N_ENCRYPTION_KEY` on a live instance.** Every credential is encrypted with it. Change it and you re-enter them all by hand — there is no recovery path.

> **Set `GENERIC_TIMEZONE` before building cron workflows.** Changing it later shifts every existing schedule's fire time at once.

## Dependencies for n8n Queue Stack Hosting

- **A Railway account** — Hobby at $5/month includes $5 of usage; expect roughly $15–25/month total for this stack.
- **Bundled services** — Postgres 18 and Redis 8.2, provisioned by the template. Node.js 22 ships inside the n8n image.
- **Volumes** — Postgres at `/var/lib/postgresql/data`, Redis at `/data`. Without them a redeploy destroys every workflow and credential.
- **Optional add-ons** — a task runner (`ghcr.io/n8n-io/runners:2.32.6-distroless`) for isolated Code-node execution, and an S3 bucket for off-platform backups.

### Deployment Dependencies

- [n8n on GitHub](https://github.com/n8n-io/n8n)
- [n8n documentation](https://docs.n8n.io)
- [n8n queue mode guide](https://docs.n8n.io/hosting/scaling/queue-mode/)
- [Railway private networking](https://docs.railway.com/networking/private-networking)

### Implementation Details

Both n8n services run `ghcr.io/n8n-io/n8n:2.32.6`, differing only in start command: the main service serves the editor and API on `5678` behind the Railway domain, while `n8n-worker` starts with `n8n worker` and holds no public route. Postgres and Redis are reached by private hostname through reference variables, and all four images are pinned rather than tracking `latest`, so a redeploy months from now reproduces what you tested.

The request path is Railway edge → `n8n:5678` → Redis → `n8n-worker`. That indirection protects the editor: a ten-minute workflow occupies a worker, and the UI stays responsive because it was never going to run the job. Scale by raising replicas on `n8n-worker`, each pulling independently from the same queue, and leave `n8n` at one replica. Task runners are not shared — give each worker replica its own on port `5679`.

For backups, only Postgres needs protecting — Redis holds in-flight jobs and is safe to lose. Point a scheduled `pg_dump` at S3: a volume is durable, not a backup.

## Frequently Asked Questions

**Why do I need both Postgres and Redis?** Postgres is the durable store for workflows, credentials and execution history. Redis is the job broker queue mode runs on — without it the main process runs workflows itself and one heavy job blocks the editor.

**What happens if the encryption keys don't match?** The editor works and workflows save, but executions fail at runtime with decryption errors — the most common self-hosted n8n failure, and it looks like an integration bug rather than a config bug.

**How do I scale this?** Raise replicas on `n8n-worker`. Throughput scales close to linearly until Postgres becomes the bottleneck. Keep `n8n` at one replica — two editors against one queue causes duplicate trigger registration.

**Will my workflows survive a redeploy?** Yes. Everything lives in Postgres on a volume and neither n8n container holds state. Community nodes reinstall on boot with `N8N_REINSTALL_MISSING_PACKAGES=true`.

**Can I run Python in Code nodes?** Yes, inside the worker process. For isolated execution, add a task runner pointed at the worker's broker on port `5679`.

**Is n8n free for commercial use?** Yes for automating your own operations. The Sustainable Use License only restricts reselling n8n itself as a hosted product to third parties.

## Why Deploy n8n Queue Stack 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 Queue Stack on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway. Four services, pinned images and generated secrets, wired at deploy time — all that's left is to claim your owner account.

## 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-stack
