BLACK FRIDAY 2026 LIVE: RackNerd 4GB VPS $47.98/yr (Lifetime) · ElevenLabs 55% Off · Hostinger 73% Off · Amazon Local AI Hardware View Verified Deals →
High · HTTPS & Caddy

How to Fix HTTP 502 Bad Gateway (Caddy / Nginx → n8n)

TL;DR Fix

Reverse proxy is pointing to 127.0.0.1:5678 inside another container, or n8n crashed in a restart loop. Keep Caddy and n8n on the same Docker Compose bridge network.

Exact Error Signature

502 Bad Gateway | dial tcp: lookup n8n: no such host | connection refused

Copy-Paste Fix Commands

docker compose ps && docker compose logs --tail=50 n8n
# In Caddyfile, proxy to Docker service name (NOT localhost):
# reverse_proxy n8n:5678

Preventing Recurrence

Keep Caddy and n8n on the same Docker Compose bridge network.

More Production Error Fixes