Skip to content

Commit 5d628e1

Browse files
Merge pull request #7 from Islamhassana3/copilot/fix-8d247ed1-b6eb-44f6-ac7e-1c452be7795e
[WIP] the issue where only the n8n service and not the n8n service and the postgrees service with the n8n service flowing into the postgres encased togeteher
2 parents f456399 + 2ec9d07 commit 5d628e1

8 files changed

+488
-22
lines changed

ENVIRONMENT_VARIABLES.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Environment Variables for Railway Deployment
22

3-
## Service: MySQL Database
3+
## Option 1: MySQL Database
4+
5+
### Service: MySQL Database
46

57
```bash
68
MYSQL_ROOT_PASSWORD=secure_root_password_here
@@ -9,15 +11,15 @@ MYSQL_USER=n8n
911
MYSQL_PASSWORD=secure_n8n_password_here
1012
```
1113

12-
## Service: N8N Server
14+
### Service: N8N Server (MySQL)
1315

1416
```bash
1517
# Authentication
1618
N8N_BASIC_AUTH_ACTIVE=true
1719
N8N_BASIC_AUTH_USER=admin
1820
N8N_BASIC_AUTH_PASSWORD=your_admin_password_here
1921

20-
# Database Connection
22+
# Database Connection (MySQL)
2123
DB_TYPE=mysqldb
2224
DB_MYSQLDB_HOST=${{mysql.RAILWAY_PRIVATE_DOMAIN}}
2325
DB_MYSQLDB_PORT=3306
@@ -33,6 +35,40 @@ N8N_PROTOCOL=https
3335
GENERIC_TIMEZONE=UTC
3436
```
3537

38+
## Option 2: PostgreSQL Database (Recommended)
39+
40+
### Service: PostgreSQL Database
41+
42+
```bash
43+
POSTGRES_DB=n8n
44+
POSTGRES_USER=n8n
45+
POSTGRES_PASSWORD=secure_n8n_password_here
46+
```
47+
48+
### Service: N8N Server (PostgreSQL)
49+
50+
```bash
51+
# Authentication
52+
N8N_BASIC_AUTH_ACTIVE=true
53+
N8N_BASIC_AUTH_USER=admin
54+
N8N_BASIC_AUTH_PASSWORD=your_admin_password_here
55+
56+
# Database Connection (PostgreSQL)
57+
DB_TYPE=postgresdb
58+
DB_POSTGRESDB_HOST=${{postgres.RAILWAY_PRIVATE_DOMAIN}}
59+
DB_POSTGRESDB_PORT=5432
60+
DB_POSTGRESDB_DATABASE=n8n
61+
DB_POSTGRESDB_USER=n8n
62+
DB_POSTGRESDB_PASSWORD=secure_n8n_password_here
63+
64+
# URLs (Railway will populate these)
65+
N8N_HOST=${{RAILWAY_PUBLIC_DOMAIN}}
66+
WEBHOOK_URL=${{RAILWAY_PUBLIC_DOMAIN}}
67+
N8N_PORT=5678
68+
N8N_PROTOCOL=https
69+
GENERIC_TIMEZONE=UTC
70+
```
71+
3672
## Service: N8N Workflow Builder
3773

3874
```bash
@@ -49,7 +85,8 @@ PORT=1937
4985

5086
## Notes
5187

52-
1. **Railway Variables**: Variables like `${{mysql.RAILWAY_PRIVATE_DOMAIN}}` are automatically populated by Railway
88+
1. **Railway Variables**: Variables like `${{postgres.RAILWAY_PRIVATE_DOMAIN}}` or `${{mysql.RAILWAY_PRIVATE_DOMAIN}}` are automatically populated by Railway
5389
2. **API Key**: Must be generated in N8N UI after deployment
5490
3. **Passwords**: Should be secure and unique for production
55-
4. **Dependencies**: Services must be deployed in order: MySQL → N8N → Workflow Builder
91+
4. **Dependencies**: Services must be deployed in order: Database (PostgreSQL/MySQL) → N8N → Workflow Builder
92+
5. **Database Choice**: PostgreSQL is recommended for better performance and features, but MySQL is also supported for compatibility

QUICK_START.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@
33
## The Problem (Solved!)
44

55
The original issue was:
6-
> "its still not working, I have a feeling that the sql isnt set up right as in the other version it has like n8n with a arrow to mysql. (on railway.app)"
6+
> "the issue where only the n8n service and not the n8n service and the postgrees service with the n8n service flowing into the postgres encased togeteher"
77
8-
**The user expected a complete n8n setup with database, not just the workflow builder client.**
8+
**The user expected a complete n8n setup with PostgreSQL database properly connected to n8n, not just the workflow builder client.**
99

1010
## The Solution ✅
1111

12-
This repository now provides a **complete N8N automation stack** for Railway deployment:
12+
This repository now provides a **complete N8N automation stack** for Railway deployment with proper database connectivity:
1313

14+
**PostgreSQL Stack (Recommended):**
15+
```
16+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
17+
│ PostgreSQL DB │◄───┤ N8N Server │◄───┤ Workflow Builder│
18+
│ Port: 5432 │ │ Port: 5678 │ │ Port: 1937 │
19+
│ │ │ │ │ │
20+
│ • Workflow data │ │ • Web UI │ │ • MCP Server │
21+
│ • User accounts │ │ • API endpoints │ │ • AI Integration│
22+
│ • Executions │ │ • Automations │ │ • Claude/ChatGPT│
23+
└─────────────────┘ └─────────────────┘ └─────────────────┘
24+
```
25+
26+
**MySQL Stack (Legacy):**
1427
```
1528
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
1629
│ MySQL DB │◄───┤ N8N Server │◄───┤ Workflow Builder│
@@ -24,19 +37,25 @@ This repository now provides a **complete N8N automation stack** for Railway dep
2437

2538
## 🎯 What You Get
2639

27-
1. **MySQL Database** - Stores all your workflows, user data, and execution history
40+
1. **Database** - Stores all your workflows, user data, and execution history
41+
- **PostgreSQL** (Recommended): Modern, powerful, feature-rich
42+
- **MySQL** (Legacy): Stable, widely supported
2843
2. **N8N Server** - The full n8n application with web interface
2944
3. **Workflow Builder** - MCP server for AI assistant integration
3045

3146
## 🚀 One-Click Deploy
3247

33-
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https://github.com/Islamhassana3/n8n-workflow-builder)
48+
**PostgreSQL Version (Recommended):**
49+
[![Deploy PostgreSQL Stack](https://railway.app/button.svg)](https://railway.app/new/template?template=https://github.com/Islamhassana3/n8n-workflow-builder/blob/main/railway-template-postgres.toml)
50+
51+
**MySQL Version (Legacy):**
52+
[![Deploy MySQL Stack](https://railway.app/button.svg)](https://railway.app/new/template?template=https://github.com/Islamhassana3/n8n-workflow-builder/blob/main/railway-template.toml)
3453

3554
**Or manually:**
3655

3756
1. Fork this repo
3857
2. Connect to Railway
39-
3. Deploy all 3 services
58+
3. Deploy all 3 services using the template files
4059
4. Configure environment variables
4160

4261
## 📋 Post-Deployment Setup

RAILWAY_DEPLOY.md

Lines changed: 100 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ This guide explains how to deploy a complete N8N automation stack on Railway, in
44

55
## 🏗️ Architecture
66

7-
The complete stack includes three services that work together:
7+
The complete stack includes three services that work together. You can choose between PostgreSQL (recommended) or MySQL:
88

9+
**Option 1: PostgreSQL Stack (Recommended)**
10+
```
11+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
12+
│ PostgreSQL DB │◄───┤ N8N Server │◄───┤ Workflow Builder│
13+
│ Port: 5432 │ │ Port: 5678 │ │ Port: 1937 │
14+
│ │ │ │ │ │
15+
│ • Stores workflows │ • Web UI │ │ • MCP Server │
16+
│ • User data │ │ • API endpoints │ │ • Tool access │
17+
│ • Executions │ │ • Automations │ │ • HTTP/stdio │
18+
└─────────────────┘ └─────────────────┘ └─────────────────┘
19+
```
20+
21+
**Option 2: MySQL Stack (Legacy)**
922
```
1023
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
1124
│ MySQL DB │◄───┤ N8N Server │◄───┤ Workflow Builder│
@@ -21,10 +34,59 @@ The complete stack includes three services that work together:
2134

2235
### Option 1: One-Click Deploy (Recommended)
2336

24-
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/n8n-complete-stack)
37+
**PostgreSQL Version (Recommended):**
38+
[![Deploy PostgreSQL Stack](https://railway.app/button.svg)](https://railway.app/template/n8n-postgres-stack)
39+
40+
**MySQL Version (Legacy):**
41+
[![Deploy MySQL Stack](https://railway.app/button.svg)](https://railway.app/template/n8n-mysql-stack)
2542

2643
### Option 2: Manual Setup
2744

45+
Choose your preferred database:
46+
47+
#### PostgreSQL Setup (Recommended)
48+
49+
1. **Fork this repository** to your GitHub account
50+
51+
2. **Create a new Railway project**:
52+
- Go to [Railway.app](https://railway.app)
53+
- Click "New Project" → "Deploy from GitHub repo"
54+
- Select your forked repository
55+
56+
3. **Deploy the services in order**:
57+
58+
**Step 1: Deploy PostgreSQL Database**
59+
```bash
60+
# Add PostgreSQL service
61+
railway add postgres
62+
63+
# Set environment variables
64+
railway variables set POSTGRES_DB=n8n
65+
railway variables set POSTGRES_USER=n8n
66+
railway variables set POSTGRES_PASSWORD=your_secure_n8n_password
67+
```
68+
69+
**Step 2: Deploy N8N Server**
70+
```bash
71+
# Add n8n service
72+
railway add n8n
73+
74+
# Set environment variables for n8n
75+
railway variables set N8N_BASIC_AUTH_ACTIVE=true
76+
railway variables set N8N_BASIC_AUTH_USER=admin
77+
railway variables set N8N_BASIC_AUTH_PASSWORD=your_admin_password
78+
railway variables set DB_TYPE=postgresdb
79+
railway variables set DB_POSTGRESDB_HOST=${{postgres.RAILWAY_PRIVATE_DOMAIN}}
80+
railway variables set DB_POSTGRESDB_PORT=5432
81+
railway variables set DB_POSTGRESDB_DATABASE=n8n
82+
railway variables set DB_POSTGRESDB_USER=n8n
83+
railway variables set DB_POSTGRESDB_PASSWORD=your_secure_n8n_password
84+
railway variables set N8N_HOST=${{RAILWAY_PUBLIC_DOMAIN}}
85+
railway variables set WEBHOOK_URL=${{RAILWAY_PUBLIC_DOMAIN}}
86+
```
87+
88+
#### MySQL Setup (Legacy)
89+
2890
1. **Fork this repository** to your GitHub account
2991

3092
2. **Create a new Railway project**:
@@ -75,15 +137,35 @@ The complete stack includes three services that work together:
75137

76138
## 🔧 Environment Variables
77139

78-
### MySQL Service
140+
### PostgreSQL Service (Recommended)
141+
| Variable | Description | Example |
142+
|----------|-------------|---------|
143+
| `POSTGRES_DB` | Database name | `n8n` |
144+
| `POSTGRES_USER` | N8N user | `n8n` |
145+
| `POSTGRES_PASSWORD` | N8N user password | `secure_n8n_pass_123` |
146+
147+
### N8N Server Service (PostgreSQL)
148+
| Variable | Description | Example |
149+
|----------|-------------|---------|
150+
| `N8N_BASIC_AUTH_ACTIVE` | Enable basic auth | `true` |
151+
| `N8N_BASIC_AUTH_USER` | Admin username | `admin` |
152+
| `N8N_BASIC_AUTH_PASSWORD` | Admin password | `admin_pass_123` |
153+
| `DB_TYPE` | Database type | `postgresdb` |
154+
| `DB_POSTGRESDB_HOST` | PostgreSQL host | `${{postgres.RAILWAY_PRIVATE_DOMAIN}}` |
155+
| `DB_POSTGRESDB_PORT` | PostgreSQL port | `5432` |
156+
| `DB_POSTGRESDB_DATABASE` | Database name | `n8n` |
157+
| `DB_POSTGRESDB_USER` | Database user | `n8n` |
158+
| `DB_POSTGRESDB_PASSWORD` | Database password | `secure_n8n_pass_123` |
159+
160+
### MySQL Service (Legacy)
79161
| Variable | Description | Example |
80162
|----------|-------------|---------|
81163
| `MYSQL_ROOT_PASSWORD` | Root password | `secure_root_pass_123` |
82164
| `MYSQL_DATABASE` | Database name | `n8n` |
83165
| `MYSQL_USER` | N8N user | `n8n` |
84166
| `MYSQL_PASSWORD` | N8N user password | `secure_n8n_pass_123` |
85167

86-
### N8N Server Service
168+
### N8N Server Service (MySQL)
87169
| Variable | Description | Example |
88170
|----------|-------------|---------|
89171
| `N8N_BASIC_AUTH_ACTIVE` | Enable basic auth | `true` |
@@ -155,7 +237,7 @@ After deployment, you'll have three services:
155237

156238
- **N8N Web UI**: `https://n8n-[project-id].up.railway.app`
157239
- **Workflow Builder API**: `https://workflow-builder-[project-id].up.railway.app`
158-
- **MySQL**: Internal only (`mysql.railway.internal:3306`)
240+
- **Database**: Internal only (`postgres.railway.internal:5432` or `mysql.railway.internal:3306`)
159241

160242
## 🛠️ Usage Examples
161243

@@ -202,14 +284,21 @@ curl -X POST https://your-workflow-builder.railway.app/mcp \
202284
1. **"Connection refused" errors**:
203285
- Check that services are running in Railway dashboard
204286
- Verify environment variables are set correctly
205-
- Check service dependencies (MySQL → N8N → Workflow Builder)
287+
- Check service dependencies (Database → N8N → Workflow Builder)
206288

207289
2. **N8N can't connect to database**:
208-
- Verify MySQL service is healthy
209-
- Check database environment variables match
210-
- Ensure MySQL user has proper permissions
211-
212-
3. **Workflow Builder can't connect to N8N**:
290+
- Verify database service (PostgreSQL/MySQL) is healthy
291+
- Check database environment variables match between services
292+
- Ensure database user has proper permissions
293+
- For PostgreSQL: Verify `DB_TYPE=postgresdb` and `DB_POSTGRESDB_*` variables
294+
- For MySQL: Verify `DB_TYPE=mysqldb` and `DB_MYSQLDB_*` variables
295+
296+
3. **Database connection timeout**:
297+
- PostgreSQL: Check `DB_POSTGRESDB_HOST=${{postgres.RAILWAY_PRIVATE_DOMAIN}}`
298+
- MySQL: Check `DB_MYSQLDB_HOST=${{mysql.RAILWAY_PRIVATE_DOMAIN}}`
299+
- Ensure database service is fully started before n8n starts
300+
301+
4. **Workflow Builder can't connect to N8N**:
213302
- Verify N8N service is running and accessible
214303
- Check N8N_HOST environment variable
215304
- Verify API key is valid

0 commit comments

Comments
 (0)