App with multiple networks sometimes fails with "Gateway Timeout"

My server has traefik (defined in a compose file), and multiple other apps (each in its own compose file). Each app's compose file defines a shared network; it is used by both the app and traefik. Everything works so far.

However, now I added another app (with its own compose file), and it needs multiple networks: a shared network (for it and traefik), one to be shared by it and the database, another for it and redis, etc.

For some reason, it sometimes works, and sometimes I get a Gateway Timeout error. It's really confusing - because it works for a while, then fails, I restart traefik, it works for a while, then fails, etc.

Any advice would be appreciated... thank you.

Set If using compose, make sure to give the Docker network a name, otherwise it will have a project adapted name.

1 Like


Am I understanding you correctly, do you mean like this:

docker-compose.yml for app "myapp":

  traefik-myapp:        # <---
    external: true

  # ...
    - traefik-myapp           # <---
    - posgres-myapp
    - redis-myapp
  labels: traefik-myapp    # <----------- THIS

# ...

And docker-compose.yml for traefik itself:

  traefik-myapp:            # <---

  # ...
    - traefik-portainer
    - traefik-myapp            # <---
    - traefik-gitea

# ...

If so, why is this necesary when there are multiple networks for an app, and not when the app has only one network? And of course, how come it works sometimes and sometimes not? :thinking:

I found another answer of yours...

...forward traffic round robin. If Traefik only shares one network (of two) with the service, every other forward will fail.

If you set, Traefik will only use that network to forward traffic to. It can be set globally or per service.

I assume that's what's happening in my case too.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.