Deploy your File Upload Website + n8n completely on Railway!
- GitHub Account - For code repository
- Railway Account - Sign up free
- Your Project Code - Already created
You'll deploy 2 services on Railway:
┌─────────────────────────────────────────────┐
│ Railway Project │
├─────────────────────────────────────────────┤
│ Service 1: File Upload Website │
│ ├─ URL: your-app.railway.app │
│ └─ Port: 3000 │
│ │
│ Service 2: n8n (Self-Hosted) │
│ ├─ URL: your-n8n.railway.app │
│ └─ Port: 5678 │
│ │
│ ✓ Connected via internal Railway network │
└─────────────────────────────────────────────┘
Go to your project folder:
cd "d:\Gitam Leaker\N8N Workflows\File Upload Project"Initialize git:
git init
git config user.name "Your Name"
git config user.email "your-email@gmail.com"git add .
git commit -m "Initial commit: File upload system"- Go to github.com/new
- Repository name:
file-upload-system - Click Create Repository
- Follow the instructions to push:
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/file-upload-system.git
git push -u origin mainNow your code is on GitHub! ✓
- Go to railway.app
- Login with GitHub
- Click "New Project"
- Select "Deploy from GitHub Repo"
- Click "Configure GitHub App"
- Authorize Railway
- Select your
file-upload-systemrepo - Click "Deploy"
Railway will auto-detect Node.js and install dependencies!
- Go to "Variables" tab
- Add these variables:
PORT=3000
N8N_WEBHOOK_URL=https://YOUR_N8N_URL/webhook/file-upload
NODE_ENV=production
Don't know N8N_WEBHOOK_URL yet? We'll set it after deploying n8n.
- Railway assigns automatic URL:
your-project-abc123.railway.app - Visit it → Your website is live! ✓
- Save this URL for later
Example: https://file-upload-9xk2.railway.app
Create a new GitHub repo named n8n-railway:
mkdir n8n-railway
cd n8n-railway
git initCreate file named Dockerfile:
FROM n8nio/n8n
EXPOSE 5678
ENV N8N_SECURE_COOKIE=false
ENV N8N_PROTOCOL=https
ENV N8N_HOST=YOUR_N8N_DOMAIN.railway.app
ENV N8N_PORT=5678
ENV N8N_EDITOR_BASE_URL=https://YOUR_N8N_DOMAIN.railway.app/
ENV N8N_WEBHOOK_TUNNEL_URL=https://YOUR_N8N_DOMAIN.railway.app/
# Optional: Database persistence
# This uses SQLite by default, stored in /home/node/.n8n
VOLUME ["/home/node/.n8n"]
CMD ["n8n", "start"]For local testing:
version: '3.8'
services:
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
- N8N_SECURE_COOKIE=false
- N8N_PROTOCOL=http
- N8N_HOST=localhost
- N8N_PORT=5678
volumes:
- n8n_storage:/home/node/.n8n
volumes:
n8n_storage:git add .
git commit -m "Initial n8n setup"
git remote add origin https://github.com/YOUR_USERNAME/n8n-railway.git
git push -u origin main- Go to Railway → New Project
- Select GitHub repo:
n8n-railway - Railway detects Docker automatically
- Click Deploy
If you prefer simpler setup without Docker:
- Create
package.json:
{
"name": "n8n-railway",
"version": "1.0.0",
"scripts": {
"start": "n8n start"
},
"dependencies": {
"n8n": "latest"
}
}- Create
Procfile:
web: npm start
- Push to GitHub and deploy same way
After n8n deployment completes:
- Railway assigns URL:
your-n8n-abc.railway.app - This is your n8n instance!
Example: https://n8n-file-upload-xyz.railway.app
- Visit:
https://your-n8n-abc.railway.app - First time: Create admin password
- You're in! ✓
- New Workflow
- Add Webhook node
- Set:
- Authentication: None
- Method: POST
- Click "Test" or "Execute Workflow"
- Copy the full webhook URL (shown at bottom)
Example: https://your-n8n-abc.railway.app/webhook/WORKFLOW_ID/trigger
- Go to Railway Dashboard
- Select File Upload Website service
- Go to Variables
- Update:
N8N_WEBHOOK_URL=https://your-n8n-abc.railway.app/webhook/WORKFLOW_ID/trigger - Railway auto-redeploys! ✓
# From your terminal, test the webhook:
curl -X POST https://your-n8n-abc.railway.app/webhook/WORKFLOW_ID/trigger \
-H "Content-Type: application/json" \
-d '{
"recipientEmail": "your-email@gmail.com",
"senderName": "Test",
"file": {
"filename": "test.txt",
"size": 1024,
"filepath": "/tmp/test.txt",
"mimetype": "text/plain"
},
"timestamp": "2024-01-27T12:00:00Z"
}'- In n8n Dashboard: Click Import
- Select
n8n-workflow.jsonfrom your project - Configure Gmail credentials
- Activate workflow ✓
- New Workflow
- Add nodes:
- Webhook (trigger)
- Gmail (send email)
- Set (response)
Gmail Node Configuration:
From: myn8nuploade@gmail.com
To: {{ $json.recipientEmail }}
Subject: 📎 File Attachment: {{ $json.file.filename }}
Body (HTML):
<h2>File Attachment</h2>
<p>Hi,</p>
<p>{{ $json.senderName }} sent you a file!</p>
<p><strong>File:</strong> {{ $json.file.filename }}<br>
<strong>Size:</strong> {{ ($json.file.size/1024/1024).toFixed(2) }} MB</p>
<p>See attachment below.</p>
- Test and activate ✓
- Go to Credentials → New → Gmail
- Click OAuth2 Connection
- Click "Connect my account"
- Sign in with:
myn8nuploade@gmail.com - Grant permissions
- Done! ✓
If OAuth doesn't work:
- Go to myaccount.google.com
- Security → 2-Step Verification
- Scroll down → App Passwords
- Select: Mail, Windows Computer
- Copy generated password
- In n8n Gmail credential:
- Email:
myn8nuploade@gmail.com - Password: (paste app password)
- SMTP: smtp.gmail.com:587
- Email:
- Open website:
https://your-app-xyz.railway.app - Upload file with test recipient email
- Check logs in Railway
- Check n8n execution logs
- Check email inbox ✓
Website Service:
- Railway Dashboard → File Upload service
- Click "Logs" to see Node.js output
- Shows: file received, webhook triggered, responses
n8n Service:
- Railway Dashboard → n8n service
- Click "Logs" to see n8n activity
- Or in n8n Dashboard → Execution History
Website Service:
PORT=3000
NODE_ENV=production
N8N_WEBHOOK_URL=https://your-n8n.railway.app/webhook/WORKFLOW_ID
CORS_ORIGIN=https://your-app.railway.app
n8n Service:
N8N_SECURE_COOKIE=true
N8N_PROTOCOL=https
N8N_HOST=your-n8n.railway.app
N8N_ENCRYPTION_KEY=your-secure-random-key
N8N_DB_TYPE=sqlite
By default: SQLite (file-based)
- Persists in
/home/node/.n8n - Good for small projects
For production with multiple instances:
- Add PostgreSQL service in Railway
- Update n8n environment variables
- Files stored in
/uploadsdirectory - Temporary storage (cleaned up)
- Good for small/medium load
Consider moving to cloud storage:
Option 1: AWS S3
npm install aws-sdkUpdate server.js to upload to S3 instead of local directory.
Option 2: Railway Volumes (Easy!)
Add volume to website service in Railway:
/uploads:/mnt/uploads
This persists uploaded files.
Option 3: Google Cloud Storage
- Create bucket
- Store files there instead
- Cost: ~$0.02/GB
Website Service → Logs:
Server running on http://localhost:3000
File uploaded: document.pdf
Webhook triggered: https://your-n8n...
n8n Service → Logs:
n8n started
Workflow executed
Email sent: user@example.com
# Check if services are running
curl https://your-app-xyz.railway.app/health
# Should return: {"status": "Server is running"}
# Test n8n
curl https://your-n8n-xyz.railway.app/api/v1/health| Component | Tier | Cost/Month |
|---|---|---|
| File Upload Website | Hobby ($5 credit/month) | Free* |
| n8n Service | Hobby | Free* |
| Database (PostgreSQL) | Optional | $15+ |
| Total | Free-$15/mo |
*Free tier: $5/month credit (covers both services)
Paid plans:
- Standard: $20/month usage + costs
- Pro: $50/month + costs
Railway auto-deploys when you push to GitHub!
# Make changes locally
cd d:\Gitam Leaker\N8N Workflows\File Upload Project
# ... edit files ...
# Push to GitHub
git add .
git commit -m "Update email template"
git push origin main
# Railway automatically redeploys! ✓
# Check Railway logs to confirm| Problem | Solution |
|---|---|
| Website can't connect to n8n | Check webhook URL in Railway variables |
| n8n webhook returns 404 | Verify webhook path in n8n node |
| Gmail not sending | Check OAuth credentials in n8n |
| Files not uploading | Check /uploads directory permissions |
| Services won't start | Check logs in Railway dashboard |
After everything is deployed:
| Service | URL |
|---|---|
| Website | https://your-app-xyz.railway.app |
| n8n | https://your-n8n-xyz.railway.app |
| n8n Webhook | https://your-n8n-xyz.railway.app/webhook/WORKFLOW_ID |
Your complete system is now live on Railway:
- ✅ Website hosted and accessible
- ✅ n8n self-hosted and running
- ✅ Webhook connected
- ✅ Email automation working
- ✅ Auto-deployed on code push
Next Steps:
- Share your website URL with users
- Monitor logs regularly
- Keep dependencies updated
- Add custom domain (optional)
Everything running on Railway, zero server management needed! 🚀