Deploy n8n

n8n with Postgres: workflow automation and AI agents, no execution limits

Deploy n8n

/var/lib/postgresql/data

Just deployed

/home/node/.n8n

Deploy and Host n8n on Railway

n8n is an open source workflow automation tool: connect 400+ apps and APIs, build AI agents, run webhooks and schedules, and write JavaScript or Python where a node is not enough. This template self-hosts it on Railway with a Postgres database, so you get unlimited workflows and executions for the cost of the resources you use.

About Hosting n8n

The template deploys two services. n8n runs the official n8nio/n8n:stable image and is served over Railway's HTTPS domain. Postgres runs Railway's own Postgres image and stores your workflows, credentials and execution history on its own volume. n8n has a second volume at /home/node/.n8n, so installed community nodes, binary files and settings survive restarts and redeploys too.

Everything is wired for you: the database connection uses Railway's private network, the public URL is filled in for webhooks and OAuth callbacks, and a random N8N_ENCRYPTION_KEY is generated to encrypt your stored credentials.

Common Use Cases

  • Replacing Zapier or Make with self-hosted automations that have no per-task pricing
  • AI agents and chatbots that call OpenAI, Anthropic, Gemini or local models, with tools from community nodes
  • Webhooks, scheduled jobs, API integrations and syncing data between apps and databases

Dependencies for n8n Hosting

  • Postgres (included in this template, with its own volume)
  • An n8n owner account, which you create on first visit

Implementation Details

Open the Railway domain of the n8n service after the deploy finishes and create the owner account. The first start runs the database migrations, which can take a few minutes; the editor URL appears in the deploy logs when n8n is ready.

Webhook URLs use your Railway domain automatically. If you add a custom domain, change N8N_HOST and N8N_WEBHOOK_URL to it.

Back up N8N_ENCRYPTION_KEY from the n8n Variables. If it is lost or changed, credentials stored in n8n cannot be decrypted.

Execution data older than 7 days is pruned automatically (EXECUTIONS_DATA_MAX_AGE, in hours) so the database stays small. Set GENERIC_TIMEZONE to your time zone so schedules run when you expect. To update n8n, redeploy the service: it pulls the latest stable release.

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.


Template Content

More templates in this category

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

jakemerson
121
View Template
Evolution API with n8n
Automate WhatsApp workflows with Evolution API, n8n, and Postgres.

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

Railway Templates
865