Skip to content

504 gateway timeout on first request after container restart on multi-network stacks #4040

Description

@orey-aajaamu

To Reproduce

  1. Create a stack with a service that has two networks — one internal (for inter-service communication) and the external dokploy network
  2. Deploy the stack
  3. Let it sit idle for a day or two, or manually restart the service container
  4. Hit the site — first request gives 504
  5. Reload Traefik — works fine after

Current vs. Expected behavior

Current:
After a container restart Traefik picks the internal network IP for routing instead of the external dokploy network IP. Since Traefik can't reach the internal network, all requests time out with 504 until Traefik is reloaded.

Expected:
Traefik should always route via the external dokploy network IP. Auto-injecting traefik.docker.network=<dokploy_external_network> on any service that has Traefik labels would ensure this.

Provide environment information

OS: Ubuntu 25.04
Dokploy: V0.28.7

Which area(s) are affected? (Select all that apply)

Docker Compose

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

When a service is on multiple networks, Traefik's network selection is non-deterministic. It picks whichever Docker reports first, which can change between restarts. Manually adding traefik.docker.network=<external_network> to the service labels fixes it permanently. Dokploy should inject this automatically when generating Traefik labels for multi-network services.

Will you send a PR to fix it?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions