Welcome to the n8n community @jelica
The 502 Bad Gateway error that occurs after the update of n8n is usually due to compatibility issues between the new n8n version and your existing setup, or resource limitations on your VPS.
Solutions to Try:
1. Check n8n Container Logs (Most Important)
First, see what’s actually failing:
docker logs n8n --tail 100 -f
Look for errors like:
2. Increase Memory Limits
Newer n8n versions need more resources. Update your docker-compose.yml:
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
deploy:
resources:
limits:
memory: 2G # Increase from default
reservations:
memory: 1G
environment:
- NODE_OPTIONS=--max-old-space-size=2048
# ... rest of config
3. Fix Task Runner Issues (n8n 2.x)
If you updated to n8n 2.x, you may need to configure runners:
Option A: Use Internal Runners (Simpler)
services:
n8n:
image: n8nio/n8n:latest
environment:
- N8N_RUNNERS_MODE=internal # Add this
# ... rest of config
Option B: Add External Runners (if needed)
services:
n8n:
image: n8nio/n8n:latest
environment:
- N8N_RUNNERS_MODE=external
- N8N_RUNNERS_TASK_BROKER_URI=n8n-task-runner-js:5679
depends_on:
- n8n-task-runner-js
n8n-task-runner-js:
image: n8nio/n8n-task-runner-js:latest
restart: unless-stopped
environment:
- N8N_RUNNERS_TASK_BROKER_URI=ws://n8n:5679
4. Update Nginx Configuration
Newer n8n versions may need updated Nginx settings for WebSockets:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
# WebSocket support (critical for n8n)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Standard proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Timeouts
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
# Buffer settings
proxy_buffering off;
}
}
After updating Nginx config:
sudo nginx -t # Test configuration
sudo systemctl reload nginx
5. Check Port Conflicts
Verify n8n is actually running and listening:
docker ps # Check if container is running
docker exec n8n netstat -tuln | grep 5678 # Check if port is bound
curl http://localhost:5678 # Test direct access
6. Rollback to Previous Version (If Needed)
If the issue persists, temporarily rollback:
services:
n8n:
image: n8nio/n8n:2.9.3 # Use specific working version
# ... rest of config
Then:
docker-compose down
docker-compose pull
docker-compose up -d
7. Check VPS Resources
Hostinger VPS might be running out of resources:
# Check memory usage
free -h
# Check disk space
df -h
# Check CPU usage
top
# Check Docker stats
docker stats n8n
If memory is low, consider:
-
Upgrading your VPS plan
-
Reducing other services
-
Adding swap space
8. Database Migration Issues
If you’re using PostgreSQL/MySQL, check for migration errors:
docker logs n8n | grep -i "migration\|database"
If migrations failed, you may need to:
The most common cause after updates is either the task runner configuration or insufficient memory on the VPS.