If you’re searching for a simple, reliable way to set up n8n hosting on Railway, this guide is for you. Railway makes deployment effortless while giving you a scalable environment to run N8N, the powerful workflow automation tool.
In this article, I’ll walk you through detailed, human-readable steps for hosting n8n on Railway, including setting up Postgres, configuring environment variables, securing your instance, and enabling webhook/queue mode for production.
Why Choose Railway for n8n Hosting?
Before we dive into the steps, here’s why Railway + n8n is such a great combo:
- One-click deployment: Railway templates make deploying n8n fast and hassle-free.
- Database integration: Postgres and Redis are easily added with plugins.
- Scalability: Run multiple services (main UI + workers) with environment variables.
- Developer-friendly: Clean UI, great logs, and secret management built-in.
With that said, let’s get straight into the step-by-step setup for n8n hosting Railway.
Step 1: Create Your Railway Account

- Go to Railway and sign up (you can use GitHub or email).
- Create a new project — this will be the container for your n8n app.
Step 2: Deploy the n8n Template

- Inside your Railway project, click New → Template.
- Search for “n8n” and click Deploy.
- Railway will automatically set up an n8n service, often with a Postgres plugin included.
Step 3: Connect Postgres Database
- Go to your project dashboard.
- Find the Postgres plugin → Variables.
- Copy the connection variables (
DATABASE_URL,PGHOST,PGUSER,PGPASSWORD,PGDATABASE). - These will be added to the n8n service in the next step.
👉 Without Postgres, n8n defaults to SQLite, which is not stable for production. That’s why using Postgres is essential.
Step 4: Configure Environment Variables for n8n
In your n8n service → Variables, add the following (replace placeholders with actual values):
DB_TYPE=postgresdb
DB_POSTGRESDB_URL=${Postgres.DATABASE_URL}
N8N_ENCRYPTION_KEY=<your-generated-key>
WEBHOOK_URL=https://<your-railway-domain>/
N8N_HOST=0.0.0.0
N8N_PORT=5678
N8N_PROTOCOL=https
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=<strong-password>
Important notes:
N8N_ENCRYPTION_KEY— generate this once usingopenssl rand -hex 32. Save it securely.WEBHOOK_URL— must match your Railway domain (https://something.up.railway.app/).- Basic Auth keeps your instance secure.
Step 5: (Optional) Enable Queue Mode with Redis
For production stability:
- Add Redis to your project (Plugins → Redis).
- Add these variables to n8n:
EXECUTIONS_MODE=queue
QUEUE_BULL_REDIS_URL=${Redis.REDIS_URL}
- Create at least one worker service using the same n8n image + identical
N8N_ENCRYPTION_KEY.
👉 This ensures long workflows don’t block your main UI.
Step 6: Redeploy & Verify
- After setting environment variables, click Deploy.
- Railway rebuilds your service with the new settings.
- Open your Railway domain → log in with Basic Auth.
- Test with a simple workflow: Webhook → Set → Respond.
Step 7: Backup & Security Checklist
- Use
pg_dumpto backup Postgres regularly. - Store
N8N_ENCRYPTION_KEYin a password manager. - Use strong Basic Auth credentials.
- Monitor logs in Railway for errors.
Troubleshooting Common Issues
- Credentials not decrypting: Your encryption key changed. Restore the original.
- Webhook redirecting to localhost: Set
WEBHOOK_URLcorrectly. - Workers idle: Ensure
EXECUTIONS_MODE=queueand same encryption key on all services. - Database errors: Check
DB_TYPE=postgresdbandDB_POSTGRESDB_URL.
Final Checklist for n8n Hosting on Railway
- Postgres configured and connected.
N8N_ENCRYPTION_KEYset and saved.WEBHOOK_URLpoints to Railway domain.- Basic Auth enabled.
- Optional Redis + queue mode set up.
- Backups in place.
🎯 Conclusion
That’s it! You now have n8n hosting on Railway running with a production-ready setup. Railway makes it easy to deploy and scale n8n with minimal DevOps overhead.
Start experimenting with n8n workflows today, automate your processes, and take advantage of Railway’s seamless deployment.
With this setup, you can confidently run automation workflows for your business, side project, or clients — without worrying about downtime or lost data.