---
title: "Deploy N8N"
description: "n8n in queue mode: main, workers, Redis and Postgres. Scale workers."
category: "Automation"
url: https://railway.com/deploy/n8n-4
---

# Deploy N8N

n8n in queue mode: main, workers, Redis and Postgres. Scale workers.

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

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

- **Creator:** darseen
- **Category:** Automation

## Template content

### n8n https://devicons.railway.com/i/n8n.svg

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

### Redis https://devicons.railway.com/i/redis.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-worker https://devicons.railway.com/i/n8n.svg

- **Image:** n8nio/n8n:2.40.7
- **Start command:** `/sbin/tini -- /docker-entrypoint.sh worker`
- **Health check:** /healthz/readiness

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

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

## Documentation

# Deploy and Host N8N on Railway

**This variant: n8n in queue mode with workers.** A main instance, a worker service you can scale, Redis and Postgres. n8n is an open-source workflow automation platform with 400+ integrations, AI agent nodes and a visual editor: a self-hosted alternative to Zapier and Make with no per-execution fees.

## About Hosting N8N

This template deploys n8n's scaling architecture as four services:

- `n8n`: the editor, API, triggers and webhooks. It turns every trigger into a job on the queue instead of running it.
- `n8n-worker`: pulls jobs from Redis and runs the executions, including test runs from the editor.
- `Redis`: the job queue.
- `Postgres`: workflows, credentials, execution history and binary data.

Every n8n service is pinned to 2.40.7. The first boot runs n8n's database migrations, which takes about a minute before the healthchecks on `/healthz/readiness` turn green. Then open the public URL and **create the owner account right away**: the first visitor to an unclaimed instance becomes its owner.

## Common Use Cases

- Run heavy or long workflows without slowing down the editor
- Absorb bursts of webhooks and scheduled jobs by adding worker replicas
- Build production AI agents and automations for a team

## Dependencies for N8N Hosting

- Nothing to bring. Every secret (Postgres and Redis passwords, n8n encryption key) is generated at deploy time.
- Optional: API keys for the services your workflows connect to, added later as n8n credentials.

### Deployment Dependencies

- n8n: https://github.com/n8n-io/n8n
- Docker image: https://hub.docker.com/r/n8nio/n8n
- Queue mode docs: https://docs.n8n.io/hosting/scaling/queue-mode/

### Implementation Details 

- **Other N8N variants.** This creator also publishes n8n with Postgres only, workers plus webhook processors behind one URL, a single-service SQLite version, and a version with external task runners for Python Code nodes.
- **Scaling.** Add replicas to `n8n-worker` in its settings, or raise `N8N_CONCURRENCY_PRODUCTION_LIMIT` (executions per replica, default 10; n8n recommends 5 or more).
- **Shared settings.** Workers read `N8N_ENCRYPTION_KEY`, the URLs and the timezone from `n8n` through reference variables, so they always match the main instance. Back up the encryption key: without it, stored credentials cannot be decrypted.
- **No volumes on n8n services.** In queue mode n8n stores binary data in Postgres by default, and `N8N_REINSTALL_MISSING_PACKAGES=true` reinstalls community nodes on every boot of every service, so nothing needs a disk.
- **Worker health.** `QUEUE_HEALTH_CHECK_ACTIVE=true` turns on the worker's `/healthz/readiness`, which only passes once the worker can reach Postgres and Redis.
- **Custom domain.** After adding one, set `N8N_EDITOR_BASE_URL` and `N8N_WEBHOOK_URL` on `n8n` to `https://your-domain`; the worker picks them up by reference.
- **Upgrading.** Main and workers must run the same version. Change the `n8nio/n8n` tag on both services, then redeploy both.

## Why Deploy N8N 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 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.



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