Django "Detected change in ..., reloading" Error in Docker
Asked Answered
T

1

8

I'm having a problem which I don't understand, and therefore can't resolve.

I have a Dockerised Django project, which I created using Cookiecutter Django months ago. Today, my development environment has started displaying the following error on every request:

code of error

I am not currently having this issue in production. I tried rolling back to commits that worked properly before (1 week old commits, for example), and I'm still getting this error.

The reloading is causing connections to the database to close and therefore my project isn't working properly at all.

Does anyone know what causes this, and how I might fix it? It feels like an issue with my Docker setup, but that hasn't changed in months, so I don't understand why that would change now.

Many Thanks for any help anyone can offer!

Tiphane answered 24/2, 2023 at 15:16 Comment(3)
I have a project dealing with the exact same peculiar behavior. Can you list your versions for Django, Docker, etc.?Enlarger
Django version 3.2.12. Docker version 4.10.1. I have tested the project on another machine and it works fine, which leads me to think it's an issue with my machine somehow rather than the project itself?Tiphane
I'm having the exact same issue starting today, django 4.0.7, docker version 23.0.1.Bersagliere
B
7

Solution:

remove Werkzeug[watchdog] from your requirements and replace it with just Werkzeug, then rebuild your docker container.

Explanation:

There's an issue with the watchdog Werkzeug backend which is included in new cookiecutter-django projects by default. Relevant thread here: https://github.com/cookiecutter/cookiecutter-django/issues/4179.

Bersagliere answered 27/2, 2023 at 11:58 Comment(1)
Thanks so much for this - sorted it out perfectly. Really appreciate you taking the time to post and point me in the right direction.Tiphane

© 2022 - 2024 — McMap. All rights reserved.