Back · Hosting
paas

Railway

Deploy n8n from a template in minutes.

Difficulty
Monthly cost from: ~$5–20/mo usage-based
Best for: Prototyping and small teams that want zero infra work.

Railway is a PaaS that deploys the official n8n Docker image with usage-based billing and a Postgres plugin — no server management at all.

Pros

  • Deploys from GitHub or template in seconds
  • Managed Postgres addon
  • Generous free trial

Cons

  • Sleep-on-idle on smaller plans can break webhooks
  • Costlier at scale than a plain VPS

Prerequisites

  • A Railway account (GitHub login works)
  • A credit card once past the free trial credit
  • Optional custom domain

Step-by-step guide

  1. Step 1

    Deploy the n8n template

    Use Railway's official n8n template from the template gallery (one click).

  2. Step 2

    Add a Postgres plugin

    Attach Railway's managed Postgres and let it inject DB_* env vars automatically.

  3. Step 3

    Set required env vars

    Set N8N_HOST to the Railway-provided domain (or your custom domain), WEBHOOK_URL, and N8N_ENCRYPTION_KEY.

  4. Step 4

    Deploy & attach a custom domain

    Railway auto-issues HTTPS; add a CNAME if using your own domain.

Scaling & queue mode

Railway scales vertically by adjusting the service's memory/CPU limits; for queue mode, deploy a second Railway service running `n8n worker` pointed at the same Redis/Postgres instances.

Backup & upgrade

Enable Railway's automated Postgres backups in the plugin settings; upgrade n8n by redeploying with a newer image tag from the template settings.

Security checklist

  • Always run behind HTTPS (Caddy/Traefik/Nginx + Let's Encrypt) — never expose port 5678 directly.
  • Set a strong, permanent N8N_ENCRYPTION_KEY and back it up (losing it breaks stored credentials).
  • Use Postgres, not the default SQLite, for anything beyond local testing.
  • Enable N8N_BASIC_AUTH or an SSO/proxy layer if the instance is reachable from the internet.
  • Restrict inbound firewall rules to 80/443 (and SSH from your IP only).
  • Keep the n8n image pinned and update on a schedule instead of always using :latest in production.

Cost breakdown

  • Free trial credit$5 one-time
  • Hobby plan usage~$5–20/mo

Troubleshooting & FAQ

+Can I use SQLite instead of Postgres?

n8n defaults to SQLite, which works for testing but isn't recommended for production: no concurrent writers, harder backups, and risk of corruption under load. Use Postgres for anything real.

+My webhooks return 404 / don't trigger — why?

WEBHOOK_URL must match the public HTTPS URL exactly (including trailing slash), and the workflow must be activated (not just saved) for production webhook URLs to work.

+How do I move from Railway to another host later?

Export workflows/credentials with the n8n CLI (`n8n export:workflow --all` / `export:credentials --all`) or the REST API, restore the Postgres dump on the new host, then import.

+Do I lose data if the container restarts?

No, as long as n8n_data and the Postgres volume are mounted as named Docker volumes (not ephemeral container storage), your data persists across restarts and image updates.