TraefikDocker

Traefik 504 Gateway Timeout after backend container restart on multiple networks

critical
Connection ManagementUpdated Dec 11, 2025(via Exa)
How to detect:

When a backend container attached to multiple Docker networks is restarted or redeployed (via docker-compose up -d --force-recreate), Traefik fails to update its routing configuration to the new container's IP address. Traefik's routing table continues pointing to the old, defunct IP address, resulting in 504 Gateway Timeout errors for all requests to the backend service. The ambiguity occurs because Traefik's service discovery mechanism cannot determine which network to use when multiple networks are attached to the container.

Recommended action:

Add the label traefik.docker.network=<network_name> to the backend service's Docker Compose labels, specifying the shared network between Traefik and the backend (e.g., traefik_proxy). This explicitly tells Traefik's Docker provider which network to use for IP address discovery and routing. After adding this label, redeploy the backend service. Optionally enable and check the Traefik dashboard to verify the correct IP address is being used. This eliminates the need to manually restart Traefik after backend updates.