Railway

Deploy n8n — Self-Hosted Workflow Automation

Self-host n8n: unlimited executions, no Zapier fees. 188k+ GitHub stars.

Deploy n8n — Self-Hosted Workflow Automation

/var/lib/postgresql/data

N8n Latest Version

sahilrupani/n8n-railway

Just deployed

Deploy and Host n8n on Railway

n8n workflow builder interface

n8n is the world's most popular open-source workflow automation platform — 180k+ GitHub stars, 100M+ Docker pulls, 400+ integrations, and a fair-code license that gives you unlimited executions when you self-host. The 2.x line adds the spatial Canvas UI, autosave with versioned publishing, and a rebuilt AI Agent node with native tool-calling across Claude, GPT-4o, Gemini, and Groq. Connect APIs, databases, AI agents, and business tools with a visual builder — and drop into code whenever you need it. No per-step billing. No execution caps.


What This Template Deploys

ServicePurpose
n8n (2.x)The workflow engine and visual editor — Canvas UI, AI Agent node, on port 5678, accessible from your Railway public URL
PostgreSQL 17 (SSL)Managed Railway database for persistent storage of workflows, credentials, and execution history

Both services are pre-wired via Railway's private networking. No manual database configuration required — connection strings are injected automatically at deploy time.


About Hosting n8n

Running n8n in production means keeping a long-lived application server alive with persistent database connectivity, webhook-accessible public networking, secrets management for API credentials, and a controlled upgrade path. n8n ships new releases most weeks, so a clean self-hosted setup with persistent data and easy version control matters.

Railway handles all of it. This template provisions n8n connected to a managed PostgreSQL instance, exposes a secure HTTPS endpoint for webhooks, and manages container lifecycle, restarts, and scaling automatically. Your workflows, credentials, and execution history survive every redeploy.

Typical cost: ~$5/month on Railway's Hobby plan — versus $20/month on n8n Cloud Starter with a capped execution allowance, or more on Pro. Self-hosting on Railway gives you unlimited executions at a fraction of the cloud price, with your data on your own infrastructure.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway and wait for the initial build to complete (~2–3 minutes)
  2. Railway provisions n8n and PostgreSQL automatically — no manual linking required
  3. Set WEBHOOK_URL to your Railway public URL (required for webhook-triggered workflows)
  4. Open your Railway-assigned URL on port 5678 and set your admin email and password
  5. Start building workflows on the Canvas immediately

No SSH. No server administration. No Dockerfile maintenance.


Common Use Cases

  • Self-hosted alternative to Zapier — replace per-task billing with unlimited workflow executions; a 10-step workflow costs one execution on n8n vs 10 tasks on Zapier
  • AI agent and LLM workflow orchestration — the rebuilt 2.x AI Agent node calls tools across Claude, GPT-4o, Gemini, and Groq, with in-memory, Redis, and Postgres memory nodes
  • Webhook-based real-time integrations — expose public HTTPS webhook endpoints to receive events from Stripe, GitHub, Shopify, or any third-party service and trigger downstream actions
  • Business process automation — automate CRM updates, support ticket routing, invoice processing, Slack notifications, and cross-tool data sync without per-execution costs
  • Data pipelines and ETL — sync, transform, and route data between APIs, databases, and cloud services without deploying heavy data engineering infrastructure
  • Scheduled background jobs — run cron-based workflows for daily reports, monitoring checks, data backups, and recurring operational tasks at any frequency

Configuration

VariableRequiredDescription
DB_TYPE✅ Pre-setpostgresdb — connects n8n to the Railway PostgreSQL service
DB_POSTGRESDB_HOST✅ Auto-injectedPostgreSQL private hostname via Railway reference variable
DB_POSTGRESDB_PORT✅ Auto-injectedPostgreSQL port — defaults to 5432
DB_POSTGRESDB_DATABASE✅ Auto-injectedDatabase name from the Railway PostgreSQL service
DB_POSTGRESDB_USER✅ Auto-injectedDatabase user from the Railway PostgreSQL service
DB_POSTGRESDB_PASSWORD✅ Auto-injectedDatabase password via Railway reference variable
WEBHOOK_URL✅ RequiredSet to your Railway public URL — required for webhook-based workflows to receive external traffic
N8N_PROXY_HOPSPre-set1 — required for correct IP handling behind Railway's proxy layer
EXECUTIONS_DATA_PRUNERecommendedSet to true to prevent PostgreSQL bloat from execution history
PORTPre-set5678 — the default n8n port, auto-configured

WEBHOOK_URL must match your Railway public URL exactly for webhook triggers to work. Find it under your n8n service → Settings → Domains in the Railway dashboard.


n8n vs. Alternatives

n8n workflow automation overview

n8n (self-hosted)n8n CloudZapierMake (Integromat)
Price~$5/mo (Railway)From $20/moFrom $19.99/moFrom $9/mo
Executions✅ Unlimited❌ Capped❌ Per task/step❌ Per operation
Billing modelFlat compute costPer executionPer stepPer operation
Data ownership✅ Your infrastructure⚠️ n8n servers❌ Zapier servers❌ Make servers
Custom code✅ JS/Python + npm✅ Yes❌ Limited❌ Limited
AI Agent + memory nodes✅ Native (2.x)✅ Yes⚠️ Basic⚠️ Basic
Self-hostable✅ Yes❌ No❌ No❌ No

Dependencies for n8n Hosting

  • Railway account (Hobby plan at ~$5/month is sufficient for most use cases)
  • PostgreSQL database — provisioned automatically by this template via Railway
  • Public HTTPS endpoint for webhook-based workflow triggers (provided automatically)

Deployment Dependencies

Implementation Details

This template deploys n8n using a custom Railway-optimised Dockerfile from sahilrupani/n8n-railway, connected to a Railway-managed PostgreSQL 17 SSL instance over private networking. All workflow data, credentials, and execution history are stored in PostgreSQL — not in SQLite — making this a production-grade setup from day one.

WEBHOOK_URL is set to your Railway public URL, so webhook triggers work immediately without additional proxy configuration. N8N_PROXY_HOPS=1 ensures n8n correctly identifies client IPs behind Railway's proxy layer.

Upgrading to 2.x: n8n 2.x is "secure by default" — Code nodes can no longer read environment variables and the ExecuteCommand node is disabled. If you migrate existing workflows that relied on those, run n8n's built-in migration report first to catch breaking changes before upgrading.


Frequently Asked Questions

How much does it cost to self-host n8n on Railway? Approximately $5/month on Railway's Hobby plan for n8n and PostgreSQL with no execution caps. n8n Cloud Starter costs $20/month with a capped execution allowance. Zapier Starter counts each step as a separate billed task, so multi-step workflows consume tasks fast.

Do I lose my workflows and credentials if Railway redeploys? No. All workflows, credentials, execution history, and settings are stored in the Railway- managed PostgreSQL database, not inside the n8n container. Redeploys, version updates, and container restarts do not affect your data.

Can I use n8n's AI Agent and LangChain nodes when self-hosting? Yes. The 2.x AI Agent node with tool-calling across Claude, GPT-4o, Gemini, and Groq — plus in-memory, Redis, and Postgres memory nodes — is fully available in the self-hosted Community Edition with no execution limits or credit system.

Do webhooks work on Railway without additional configuration? Yes, as long as WEBHOOK_URL is set to your Railway public URL. Railway automatically provisions an HTTPS endpoint — set WEBHOOK_URL to that domain and external services can trigger your workflows in real time.

How do I update n8n to a newer version? n8n ships new releases most weeks. This template tracks the stable line — trigger a redeploy in Railway to pull the latest. To pin a specific version, update the tag in the sahilrupani/n8n-railway Dockerfile. Your PostgreSQL data is unaffected by updates.

Is the Community Edition missing features vs n8n Cloud? The Community Edition includes all 400+ integrations, the Canvas UI, AI Agent nodes, and core workflow features. Features gated to paid plans are enterprise-only: SSO/SAML, advanced RBAC, audit log streaming, and dedicated support SLAs.


Why Deploy and Host 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 get unlimited workflow executions, a production-grade PostgreSQL backend, automatic HTTPS webhook endpoints, and zero server administration — all for the cost of Railway's base compute. Host your automation engine alongside your databases, AI agents, and backend services on Railway with full data ownership and no execution caps.


Template Content

More templates in this category

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

jakemerson
115
View Template
Evolution API with n8n
[Jul'26] WhatsApp automation platform using Evolution API, n8n & PostgreSQL

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

Railway Templates
864