This repository contains the configuration needed to deploy a production-ready n8n instance on Railway.
- Create a new repository on your GitHub account.
- Push this code to the repository:
git init git add . git commit -m "Initial commit: n8n Railway config" git branch -M main git remote add origin https://github.com/yourusername/your-repo-name.git git push -u origin main
- Log into your Railway Dashboard.
- Click New Project -> Deploy from GitHub repo.
- Select the repository you just pushed.
- Don't deploy yet if prompted, we need to add a database and variables.
- In your Railway project, click New -> Database -> Add PostgreSQL.
- Wait for it to deploy.
- Click on your
n8nservice block in the Railway canvas. - Go to the Variables tab.
- Add the following variables:
N8N_HOST: (Wait until step 5 to get your public domain, then fill this in withouthttps://)WEBHOOK_URL: (Wait until step 5 to get your public domain, then fill this in withhttps://)N8N_PROTOCOL:httpsN8N_ENCRYPTION_KEY: A long, random string (e.g.your-super-secret-key-12345). Keep this safe!DB_TYPE:postgresdbDB_POSTGRESDB_DATABASE:${PGDATABASE}DB_POSTGRESDB_HOST:${PGHOST}DB_POSTGRESDB_PORT:${PGPORT}DB_POSTGRESDB_USER:${PGUSER}DB_POSTGRESDB_PASSWORD:${PGPASSWORD}
- Still in the n8n service settings, go to the Settings tab.
- Scroll down to Volumes. Click New Volume and mount it to
/home/node/.n8n. (This ensures that if your instance restarts, your active workflows and files aren't wiped). - Scroll down to Networking and click Generate Domain.
- Now, go back to the Variables tab and update
N8N_HOST(e.g.,n8n-production.up.railway.app) andWEBHOOK_URL(e.g.,https://n8n-production.up.railway.app/) with the newly generated domain.
Wait for the deployment to finish, click your public URL, and set up your owner account!