Hi @Zohar
You’re spot on suspecting both the reverse proxy and the “server lost connection” message — that’s a classic WebSocket disconnection issue, and yes, it refers to n8n, not Ollama.
Here’s how to debug and improve your setup.
What “Lost Connection” Actually Means
That message usually shows up in the UI when the WebSocket connection between your browser and n8n server is lost, often due to:
A misconfigured NGINX reverse proxy
WebSocket traffic not being upgraded correctly
Timeout or low memory (esp. on 512MB droplets)
Let’s Review Your NGINX Config
Your config looks mostly right, but here’s a refined version with a few fixes and clarifications:
Updated NGINX Config
server {
listen 443 ssl;
server_name n8n.example.com;
ssl_certificate /etc/letsencrypt/live/n8n.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# Increase buffer size for large payloads (optional, but good for AI/large responses)
client_max_body_size 100M;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
# Explicit WebSocket path
location /api/websocket/ {
proxy_pass http://localhost:5678/api/websocket/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
}
Other Things to Check
- ENV Vars
Make sure n8n knows it’s behind a proxy. Add these in your .env:
VUE_APP_URL_BASE_API=https://n8n.example.com/
WEBHOOK_TUNNEL_URL=https://n8n.example.com/
N8N_HOST=localhost
N8N_PORT=5678
N8N_PROTOCOL=http
N8N_EDITOR_BASE_URL=https://n8n.example.com
N8N_DIAGNOSTICS_ENABLED=false
- Memory & Swap
Still on 512MB? If so, add swap (as in the previous message), or upgrade to 1GB minimum.
- Check Browser Console
When you see that “lost connection” error, press F12 → Console and check network tab for /api/websocket/. If it’s red with 101 or timeout errors, it confirms the WebSocket upgrade failed.
How to Debug Properly
Use curl to test WebSocket connection:
curl -i -N -H “Connection: Upgrade” -H “Upgrade: websocket”
-H “Host: n8n.example.com” -H “Origin: https://n8n.example.com”
http://localhost:5678/api/websocket/
Run nginx -t && sudo systemctl reload nginx
Watch logs: tail -f /var/log/nginx/error.log and n8n logs
I hope this helps.