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

Just deployed

Deploy and Host n8n on Railway

n8n workflow builder interface

n8n is the world's most popular open-source workflow automation platform — 188k+ GitHub stars, 100M+ Docker pulls, 500+ integrations, and a fair-code license that gives you unlimited executions when you self-host. Connect APIs, databases, AI agents, and business tools using a visual workflow builder with the flexibility to write code when you need it. No per-step billing. No execution caps. No vendor lock-in.


What This Template Deploys

ServicePurpose
n8nThe workflow engine and visual editor — runs 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 to avoid workflow downtime.

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 2,500 execution cap, or $50/month on Pro with 10,000 executions. Self-hosting on Railway gives you unlimited executions at a fraction of the cloud price.


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. Open your Railway-assigned URL on port 5678
  4. Set your admin email and password on first launch
  5. Start building workflows 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 — connect Claude, GPT-4o, or Gemini to business logic, vector databases, and APIs using n8n's native AI nodes and LangChain integration
  • 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 (2,500–10,000)❌ 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/LLM nodes✅ Native LangChain✅ 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, which means webhook triggers work immediately without additional proxy configuration. N8N_PROXY_HOPS=1 ensures n8n correctly identifies client IPs behind Railway's proxy layer.


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 for only 2,500 executions. Zapier Starter is $19.99/month for 750 tasks where each step counts separately.

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 features and LangChain nodes when self-hosting? Yes. All AI and LangChain nodes — Claude, GPT-4o, Gemini, Pinecone, Qdrant, and vector store integrations — are fully available in the self-hosted Community Edition with no execution limits or credit systems.

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? This template tracks the latest stable n8n release. Trigger a redeploy in Railway to pull the newest version. Your PostgreSQL data is unaffected. Pin to a specific version by updating the Dockerfile in the sahilrupani/n8n-railway source repo if needed.

Is the Community Edition missing features vs n8n Cloud? The Community Edition includes all 500+ integrations, AI 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
View Template
Evolution API with n8n
[Jun'26] WhatsApp automation platform using Evolution API, n8n & PostgreSQL

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

Railway Templates