# Traefik not reloading configuration when dynamic file was changed

**URL:** <https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774>\
**Category:** Traefik v2\
**Tags:** file\
**Created:** [September 20, 2019, 8:40pm UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774 "2019-09-20T20:40:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doacola](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/doacola/32/740_2.png) [@Doacola](https://community.traefik.io/u/Doacola)\
**Post date:** [September 20, 2019, 8:40pm UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774/1 "2019-09-20T20:40:14Z")

</div>

Hi,

I was trying to follow the docs regarding automatic configuration reload and noticed an issue for which I am not sure if it's isolated case for me or not.

My setup is the following(Pretty much the quick start from docs):

`docker-compose.yml`:

```auto
version: '3.7'

services:
  reverse-proxy:
    image: traefik:v2.0
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./dynamic.yml:/etc/traefik/dynamic.yml

  whoami:
    image: containous/whoami
    labels:
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"

```

`traefik.yml`

```auto
providers:
  file:
    filename: "/etc/traefik/dynamic.yml"
    watch: true
  docker:
    endpoint: "unix:///var/run/docker.sock"
api:
  insecure: true

```

`dynamic.yml`-file I tested with full copy paste from [https://docs.traefik.io/reference/dynamic-configuration/file/](https://docs.traefik.io/reference/dynamic-configuration/file/) but also with random parts from that and verified that it did load them into dashboard just fine when I restarted the container.

My issue starts when I try to modify that dynamic configuration file and it should reload the configuration:

No matter if I modify the file locally outside the container or if I just echo text into the file while being inside container shell the configuration is never reloaded even though I have set the `watch` setting to true unless I restart the container itself.

Am I doing something horribly wrong somewhere?

Docker Host OS: MacOS(10.14.4)  
Docker version: 19.03.1

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 20, 2019, 9:36pm UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774/2 "2019-09-20T21:36:35Z")

</div>

Hello,

with Docker I recommend to mount a folder instead of a file, because have some issues with fs notify on mounted file.

---

<div class="post-metadata">

**Author:** ![Doacola](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/doacola/32/740_2.png) [@Doacola](https://community.traefik.io/u/Doacola)\
**Post date:** [September 21, 2019, 7:59am UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774/3 "2019-09-21T07:59:23Z")

</div>

Hey,

I tried that but it has the exact same issue.

Mounted `./config:/etc/traefik` and confirmed that the configurations were loaded fine but no matter what I modified inside the container or outside on that dynamic file, it just didn't trigger the reload and i did also check the container logs and no mention of any reloads.

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 21, 2019, 11:26am UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774/4 "2019-09-21T11:26:42Z")

</div>

I can reproduce with filename but not with directory.

```auto
version: '3.5'

services:

  traefik:
    image: traefik:v2.0.0
    ports:
      - 80:80
    command:
      - --log.level=DEBUG
      - --api
      - --entrypoints.web.address=:80
      - --providers.file.filename=/config/dynamic.yml
      - --providers.docker.exposedbydefault=false
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.rule=Host(`traefik.docker.localhost`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.entrypoints=web"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./config/:/config/

```

Could you give more information about your environment?

---

<div class="post-metadata">

**Author:** ![Doacola](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/doacola/32/740_2.png) [@Doacola](https://community.traefik.io/u/Doacola)\
**Post date:** [September 21, 2019, 12:43pm UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774/5 "2019-09-21T12:43:42Z")

</div>

Hey,

I decided to try again but this time removed the `filename` and replaced it with `directory` and it seems to reload the dynamic config now. I have no idea why filename doesn't work but seems like directory does the same thing which I need for the project I have.

This was the configuration that seems to work but gives no console line or anything that it was reloaded:

```yaml
providers:
  file:
    directory: /etc/traefik
    watch: true
  docker:
    endpoint: "unix:///var/run/docker.sock"
    watch: true
api:
  insecure: true

```

So it seems that with filename it refuses to reload anything even with watch enabled but if it just listens the directory it does works as I can see middleware being removed / altered each time I refresh the dashboard after I emptied or modified the dynamic file.

Would have preferred to only watch for that one dynamic file but I guess this works too.

---

<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:** [November 29, 2023, 5:11pm UTC](https://community.traefik.io/t/traefik-not-reloading-configuration-when-dynamic-file-was-changed/1774/6 "2023-11-29T17:11:28Z")

</div>

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