Railway

Deploy n8n-production-stack (w/ worker & webhook)

Self-host Open-source workflow automation: 400+ integrations, AI agent

Deploy n8n-production-stack (w/ worker & webhook)

N8N Pro Stack [w/ Worker & Postgres]

/var/lib/postgresql/data

Just deployed

/data

worker

n8nio/n8n

Just deployed

Just deployed

/data

webhook

n8nio/n8n

Just deployed

n8n

Deploy and Host n8n-production-stack on Railway

Deploy a production-grade, self-hosted n8n instance on Railway in one click. This template provisions the full queue-mode architecture: a main instance (UI + API), a worker (workflow execution), a webhook processor (dedicated webhook handling), PostgreSQL for persistence, and Redis for the job queue — all pre-wired with private networking.

About Hosting n8n-production-stack

n8n is an open-source workflow automation platform that lets you connect 400+ apps, APIs, and services using a visual node editor — with the option to drop into JavaScript when you need it. Unlike SaaS tools, self-hosting n8n means your credentials and execution data never leave your infrastructure.

Key features:

  • 400+ native integrations (Slack, GitHub, Postgres, OpenAI, Stripe, and more)
  • Visual workflow builder with native code nodes (JavaScript/Python)
  • AI agent support via LangChain integration
  • Git-based version control for workflows
  • Webhook triggers, cron schedules, and event-based execution

Architecture in this template:

Incoming webhook → Webhook Processor → Redis (Bull queue) → Worker executes
Scheduled trigger → Main instance    → Redis (Bull queue) → Worker executes

The main instance never executes workflows itself — it only manages the UI and dispatches jobs. This prevents long-running workflows from blocking the editor or incoming webhooks.

Why Deploy n8n on Railway

  • Private networking — Postgres, Redis, and all n8n services communicate over Railway's internal network; nothing is unnecessarily exposed
  • Zero infrastructure config — no Nginx, no SSL certs, no Docker Compose files to maintain
  • Horizontal scaling — add more worker replicas directly from the Railway dashboard
  • Managed secretsN8N_ENCRYPTION_KEY is auto-generated and shared across services via Railway's variable references
  • One-click deploy — the entire 5-service stack is live in under two minutes

Common Use Cases

  • AI agent pipelines — orchestrate LLM calls, RAG workflows, and tool-calling agents that run reliably at scale
  • CRM and sales automation — sync leads between HubSpot, Notion, and Slack; trigger follow-up sequences based on deal stage
  • DevOps event handling — respond to GitHub webhooks, run CI checks, post deploy summaries to Slack
  • Data ETL pipelines — pull from APIs, transform with code nodes, and load into Postgres or a data warehouse on a schedule

Dependencies for n8n

  • PostgreSQL — stores workflow definitions, credentials, and execution history
  • Redis — powers the Bull job queue that coordinates work between the main instance, workers, and webhook processor

Environment Variables Reference

VariableDescriptionRequired
N8N_ENCRYPTION_KEYEncrypts stored credentials. Must be identical across all three n8n services. Auto-generated on deploy.
N8N_EDITOR_BASE_URLPublic URL of the main instance UI
WEBHOOK_URLPublic URL of the webhook processor
DB_TYPESet to postgresdb
DB_POSTGRESDB_HOSTPostgres private hostname
EXECUTIONS_MODESet to queue to enable distributed execution
QUEUE_BULL_REDIS_HOSTRedis private hostname
EXECUTIONS_DATA_PRUNEAuto-delete old execution logsRecommended
EXECUTIONS_DATA_PRUNE_MAX_COUNTMax executions to retain (default: 100)Recommended
N8N_RUNNERS_ENABLEDEnables task runner isolationRecommended
NODE_OPTIONSSet to --max_old_space_size=8192 for memory headroomRecommended

Deployment Dependencies

Self-Hosting n8n Outside Railway

For a minimal local setup with Docker Compose:

# docker-compose.yml
services:
  n8n:
    image: n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_USER=postgres
      - DB_POSTGRESDB_PASSWORD=yourpassword
      - DB_POSTGRESDB_DATABASE=n8n
      - N8N_ENCRYPTION_KEY=your-32-char-secret
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres

  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: yourpassword
      POSTGRES_DB: n8n
    volumes:
      - pg_data:/var/lib/postgresql/data

volumes:
  n8n_data:
  pg_data:
docker compose up -d
# Access n8n at http://localhost:5678

This runs a single-instance setup. For production queue mode (as deployed by this Railway template), you'd add Redis and run separate n8n worker and n8n webhook containers sharing the same DB and encryption key.

n8n vs Zapier vs Make

n8n (self-hosted)ZapierMake
PricingFree (infra cost only)From $20/monthFrom $9/month
Data privacyFull — your infraSaaSSaaS
Custom code✅ JS/Python nodesLimited
AI agents✅ Native LangChainLimitedLimited
Execution limitsNone (your hardware)Task-based capsOperation caps

n8n is the go-to choice when you need code-level flexibility, data sovereignty, or are hitting Zapier's pricing ceiling at scale.

How Much Does n8n Cost?

n8n Community Edition is free and open-source (Apache 2.0 with a Commons Clause for SaaS use). You only pay for the infrastructure you run it on. On Railway, cost depends on resource usage — typically a few dollars per month for light workloads. n8n also offers a managed cloud plan starting at ~$20/month if you prefer zero ops, but self-hosting on Railway gives you the same architecture at a fraction of the cost.

Getting Started After Deploying n8n

Once Railway finishes deploying, open the public URL assigned to the main service. You'll be prompted to create an owner account on first visit — set your email and password here. After logging in, create your first workflow by clicking New Workflow, add a trigger node (e.g. Webhook or Schedule), and chain action nodes to it. To test webhook triggers, use the URL shown in the webhook service's Railway domain — that's the dedicated processor. Your workflows and credentials are encrypted and persisted in Postgres automatically.

n8n dashboard screenshot

FAQ

What all integrations does n8n supports? n8n ships with 400+ native integration nodes covering databases, CRMs, communication tools, cloud providers, AI models, and developer APIs. You can also build custom nodes or use the HTTP Request node for anything not natively supported.

Can n8n be self-hosted for data privacy? Absolutely — that's one of the primary reasons teams choose it. All credentials are encrypted with your N8N_ENCRYPTION_KEY and stored in your own Postgres database. Nothing is transmitted to n8n's servers.

Why are there three separate n8n services in this template? Queue mode splits concerns: the main instance handles the UI and scheduling, workers execute workflows in parallel, and the webhook processor handles incoming HTTP triggers without being blocked by running workflows. This prevents any single bottleneck and allows independent scaling.

Can I scale workers horizontally? Yes. Workers are stateless — just increase the replica count for the worker service in Railway. All workers pull from the same Redis queue automatically.

What happens if a worker crashes mid-execution? The job is requeued by Bull and picked up by another available worker. The main instance and webhook processor remain unaffected.

Is the webhook processor the only service that needs a public domain? The main instance also needs a public domain for the editor UI. The worker runs with no public exposure — it only communicates with Redis and Postgres over private networking.


Template Content

More templates in this category

View Template
N8N Main + Worker
Deploy and Host N8N with Inactive worker.

jakemerson
View Template
Postgres Backup
Cron-based PostgreSQL backup to bucket storage

Railway Templates
View Template
Prefect [Updated Mar ’26]
Prefect [Mar ’26] (ETL & Automation alternative to Airflow) Self Host

shinyduo