502 Bad Gateway when backend unreachable despite router match
criticalConnection ManagementUpdated Jan 7, 2026(via Exa)
Technologies:
How to detect:
Router matches and rule is correct, but Traefik returns 502 Bad Gateway. Backend container is unreachable due to: wrong Docker network, incorrect service port, application listening on 127.0.0.1 instead of 0.0.0.0, or container in restart loop. Service may show no available backends in Traefik API.
Recommended action:
Test connectivity from Traefik container to backend with 'docker exec -it traefik sh -lc "wget -qSO- http://<backend-ip>:<port>/health"'. Verify service port in Traefik API matches application listening port. Check application binds to 0.0.0.0, not localhost. Verify container is running and healthy with 'docker ps'. Ensure both containers share a network. Set explicit loadbalancer.server.port label. Check application logs for startup errors.