# Faulty configuration cannot reach container

**URL:** <https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [March 17, 2023, 11:15pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960 "2023-03-17T23:15:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 17, 2023, 11:15pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/1 "2023-03-17T23:15:41Z")

</div>

Hello together,

I am still a big beginner with Traefik. I'm currently trying to boot a construct (first without encryption to be able to start it). Unfortunately the service doesn't seem to find the URL of the container.

Briefly a little background:  
I'm running Traefik as a Docker container. Further projects / websites I will put on the server as own Docker-Compose, and start them up. These should register with Traefik and thus be accessible.

I have created a shared network "proxy" on the server in advance.

My configuration for Traefik looks like this:

```yml
providers:
  docker:
    exposedByDefault: false
    watch: true
    allowEmptyServices: true
    network: proxy
    useBindPortIP: true

log:
  filePath: "/etc/traefik/logs/log-file.log"
  level: "ERROR"

api:
  dashboard: true
  insecure: true

## Static configuration
entryPoints:
  web:
    address: ":80"
  websecure:
    address: ":443"

certificatesResolvers:
  lets-encrypt:
    acme:
      email: kontakt@localhost
      storage: acme.json
      httpChallenge:
          entryPoint: web

```

My Docker Compose for Traefik:

```yml
version: '3'

services:
  reverse-proxy:
    image: traefik
    container_name: "traefik"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik:/etc/traefik
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik.rule=Host(`traefik.localhost`)
# - traefik.http.routers.traefik.tls.certresolver=lets-encrypt
      - traefik.http.routers.traefik.service=traefik@docker
      - traefik.http.services.traefik.loadbalancer.server.port=8080
      - traefik.http.services.traefik.loadbalancer.server.url=http://traefik:8080
    networks:
      - proxy
      - default

networks:
  proxy:
    external: true
  default:
    driver: bridge

```

The config for Docker Compose:

My separate service that is unreachable as Docker Compose:

```auto
version: '3'
services:
  mvo-web:
    build:
      context: .
      args:
        PORT: ${WEB_PORT}
    restart: unless-stopped
    container_name: "mvo-web"
    labels:
      - traefik.enable=true
      - traefik.http.routers.mvo-web.rule=Host(`neu.localhost`)
      # - traefik.http.routers.mvo-web.tls.certresolver=lets-encrypt
      - traefik.http.routers.mvo-web.service=mvo-web@docker
      - traefik.http.services.mvo-web.loadbalancer.server.port=${WEB_PORT}
      - traefik.http.services.mvo-web.loadbalancer.server.url=http://mvo-web:${WEB_PORT}
    ports:
      - ${WEB_PORT}:${WEB_PORT}
    env_file: .env
    environment:
      PORT: ${WEB_PORT}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./:/opt/app
    networks:
      - proxy
      - default

  mvo-api:
    build:
      context: container/cms/.
      args:
        PORT: ${API_PORT}
    image: strapi:latest
    restart: unless-stopped
    container_name: "mvo-api"
    labels:
      - traefik.enable=true
      - traefik.http.routers.mvo-api.rule=Host(`api.localhost`)
      # - traefik.http.routers.mvo-api.tls.certresolver=lets-encrypt
      - traefik.http.routers.mvo-api.service=mvo-api@docker
      - traefik.http.services.mvo-api.loadbalancer.server.port=${API_PORT}
      - traefik.http.services.mvo-api.loadbalancer.server.url=http://mvo-api:${API_PORT}
    ports:
      - ${API_PORT}:${API_PORT}
    env_file: .env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: ${DATABASE_HOST}
      DATABASE_PORT: ${DATABASE_PORT}
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      APP_KEYS: ${APP_KEYS}
      NODE_ENV: ${NODE_ENV}
      PORT: ${API_PORT}
    volumes:
      - ./container/cms/config:/opt/app/config
      - ./container/cms/public:/opt/app/public
      - ./container/cms/src:/opt/app/src
      - ./container/cms/extensions:/opt/app/extensions
      - ./container/cms/.env:/opt/app/.env
      - ./container/cms/package.json:/opt/app/package.json
    networks:
      - proxy
      - default

  mvo-db:
    container_name: "mvo-db"
    platform: linux/amd64
    restart: unless-stopped
    env_file: .env
    image: mariadb:latest
    environment:
      MYSQL_USER: ${DATABASE_USERNAME}
      MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_DATABASE: ${DATABASE_NAME}
    volumes:
      - strapi-data:/var/lib/mysql
      - ./container/db:/var/lib/mysql
    ports:
      - ${DATABASE_PORT}:${DATABASE_PORT}
    networks:
      - default

volumes:
  strapi-data:

networks:
  proxy:
    external: true
  default:
    driver: bridge

```

**Screenshot as seen in Traefik.**

 ![2023-03-18 00_13_30-hosts](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/9/9c699c9b45c33dc007b1316355db736acb0385d2.png)

I've been looking for a solution for days now. Unfortunately, nothing could really help so far and I hope here for a solution.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [March 18, 2023, 7:17am UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/2 "2023-03-18T07:17:59Z")

</div>

I recommend to set `docker.network` (globally on `provider.docker` or individual on the labels) so Traefik knows which Docker network to use to forward requests, as you have multiple.

`loadbalancer.server.url` [does not exist](https://doc.traefik.io/traefik/reference/dynamic-configuration/docker/) in Docker configuration discovery with labels, the target service is automatically set.

Simple [Traefik example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-traefik-dashboard-letsencrypt) with `docker-compose.yml`.

---

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 18, 2023, 3:40pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/3 "2023-03-18T15:40:02Z")

</div>

Thank you, I have now removed url. But it does not work.

Like you, I also go through a shared network. I have created the network in advance. But my problem is existing.

The problem occurs only for other docker compose which are registered separately. You can see above that they are all in the same network.

---

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 19, 2023, 2:54pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/4 "2023-03-19T14:54:28Z")

</div>

I always run into the same problem no matter what approach I take. It searches for servers in Traefik. As soon as I address a custom port, it has the problem....

It finds services like the DB and the whoami and can recognize the servers correctly. Only those with the custom ports e.g. 8084 not.

I urgently need help for this. I've been looking for a solution for weeks now!

```yml
version: '3'
services:
  wd-web:
    build:
      context: .
      args:
        PORT: ${WEB_PORT}
    restart: unless-stopped
    container_name: "wd-web"
    labels:
      - traefik.http.routers.wd-web.rule=Host(`w2.waldheim.de`)
      - traefik.http.routers.wd-web.entrypoints=websecure,web
      - traefik.http.routers.wd-web.service=wd-web-waldheimdevhomepage@docker
      - traefik.http.services.wd-web-waldheimdevhomepage.loadbalancer.server.port=${WEB_PORT}
      - traefik.http.services.wd-web-waldheimdevhomepage.loadbalancer.healthcheck.path=/health
      - traefik.http.services.wd-web-waldheimdevhomepage.loadbalancer.healthcheck.interval=10s
      - traefik.http.services.wd-web-waldheimdevhomepage.loadbalancer.healthcheck.timeout=5s
      - traefik.http.services.wd-web-waldheimdevhomepage.loadbalancer.healthcheck.port=${WEB_PORT}
      - traefik.http.services.wd-web-waldheimdevhomepage.loadbalancer.healthcheck.hostname=wd-web
      # - traefik.http.routers.mvo-web.tls.certresolver=lets-encrypt
    ports:
      - ${WEB_PORT}:${WEB_PORT}
    env_file: .env
    environment:
      PORT: ${WEB_PORT}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./:/opt/app
    networks:
      - proxy
      - default

networks:
  proxy:
    external: true
  default:
    driver: bridge

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/9/953862a51021f221d89beca9144bc1a6e7428f19.png)

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [March 19, 2023, 4:13pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/5 "2023-03-19T16:13:29Z")

</div>

> [@mwaldheim](#):
>
> `wd-web-waldheimdevhomepage@docker`

Maybe try removing `@docker`.

---

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 19, 2023, 4:38pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/6 "2023-03-19T16:38:26Z")

</div>

I don't know why I would remove that though, since Docker services are automatically registered that way, but okey. Doesn't change anything...

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [March 19, 2023, 5:27pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/7 "2023-03-19T17:27:47Z")

</div>

I never needed `@docker`.

---

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 19, 2023, 7:36pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/8 "2023-03-19T19:36:26Z")

</div>

But it doesn't change my problem... It seems to recognize everything, but does not get to the container. The problem seems to be the external docker-compose for the own service.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [March 20, 2023, 11:18am UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/9 "2023-03-20T11:18:41Z")

</div>

Do you use Docker Swarm? Is your target service/container running? Have you tried hardcoding your port?

---

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 20, 2023, 11:52am UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/10 "2023-03-20T11:52:45Z")

</div>

I work without Swarm simple Docker. Do you think it needs Swarm for that? The Container is Running. You can recreate it yourself by doing a Docker compose with Traefik and one with e.g. Whoami service from Traefik and start them one after the other and insert them with CustomPort for whoami. So 8081:80

Ports are fixed by me.

---

<div class="post-metadata">

**Author:** ![svx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/svx/32/6429_2.png) [@svx](https://community.traefik.io/u/svx)\
**Post date:** [March 20, 2023, 1:11pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/11 "2023-03-20T13:11:54Z")

</div>

Hi @mwaldheim,  
Thanks for your interest in Traefik!

I would suggest to:

- Run Traefik in [DEBUG mode](https://doc.traefik.io/traefik/observability/logs/#level)
- Start with a simplified and shorter config, once you can reach the container, extend your configuration, step-by-step
- Make sure Traefik and the container in question share the same network and Traefik is configured to use this network
- Use tools like `docker inspect` to check your container settings
- Check as a first step if you can reach the container:port without Traefik, just from container to container
- Read [Traefik Docker Documentation - Traefik](https://doc.traefik.io/traefik/providers/docker/) for more info
- Read [Traefik EntryPoints Documentation - Traefik](https://doc.traefik.io/traefik/routing/entrypoints/) for more info

Hope that helps you! Have a nice day!

---

<div class="post-metadata">

**Author:** ![mwaldheim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mwaldheim/32/6833_2.png) [@mwaldheim](https://community.traefik.io/u/mwaldheim)\
**Post date:** [March 20, 2023, 7:01pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/12 "2023-03-20T19:01:37Z")

</div>

I was able to find the problem together with a known... It was because the dockers were unhealthy. In addition, the traefik.enable always had to be performed no matter from which service.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [March 23, 2023, 7:02pm UTC](https://community.traefik.io/t/faulty-configuration-cannot-reach-container/17960/13 "2023-03-23T19:02:21Z")

</div>

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