---
title: "Deploy n8n"
description: "n8n with Postgres: workflow automation and AI agents, no execution limits"
category: "Automation"
url: https://railway.com/deploy/n8n-12
---

# Deploy n8n

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

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

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

- **Creator:** Nermin Sabanovic's Projects
- **Category:** Automation

## Template content

### Postgres https://cdn.jsdelivr.net/gh/devicons/devicon@v2.16.0/icons/postgresql/postgresql-original.svg

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

### n8n https://cdn.jsdelivr.net/npm/simple-icons@13.21.0/icons/n8n.svg

- **Image:** n8nio/n8n:stable
- **Public domain:** Yes

## Documentation

# Deploy and Host n8n on Railway

[n8n](https://n8n.io) 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.



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