Skip to content

mkdocs serve doesn't reload upon change anymore #8478

@Skaronator

Description

@Skaronator

Problem

Updated by @squidfunk with explanation + workarounds

When serving the documentation with mkdocs serve and making a change to a document in the docs folder, MkDocs does not automatically rebuild the documentation and reload the browser anymore. This was working before.

What is impacted

  • Every new virtual environment created with a fresh Material for MkDocs installation
  • Material for MkDocs' Docker image 9.6.21 and later (see below why)

Why this is happening

Click 8.3.0, which MkDocs depends on and has covered by its version range, includes some changes to how command line arguments are handled. It's still unclear whether MkDocs needs to adapt or the error is within Click. We're still waiting on the upstream maintainers to fix the issue.

Before Click 8.3.0, Click 8.2.2 was released and later yanked because of fatal behavior, so we limited the version range of Click to < 8.2.2 in 9.6.17 via #8375. However, this led to the problem that our users were unable to install Material for MkDocs alongside other packages that needed later versions of Click as reported in #8458, which is why we removed the version pin again in 9.6.21 (since 8.2.2 has been yanked by that time). The Docker images as of 9.6.21 contain the latest versions of Click that MkDocs requires, which is why they are affected as well.

Note that MkDocs is currently unmaintained, so it's unclear when a fix will land. However, we haven't been idle in the meantime: in #8461, we explain how we are handling this situation and how we intend to move forward.

Temporary solution

There are two things you can do to work around this problem and restore live reload functionality:

Use the --livereload flag explicitly

mkdocs serve --livereload

Downgrade to Click 8.2.1

pip install click==8.2.1

Subscribe to this issue to be notified when something changes.


Original report

Context

No response

Bug description

After upgrading the mkdocs-material Docker image from ghcr.io/squidfunk/mkdocs-material:9.6.20 to ghcr.io/squidfunk/mkdocs-material:9.6.21, the live-reloading feature has stopped working.

When running mkdocs serve --dev-addr=0.0.0.0:7070, the server starts and serves the site correctly. However, it no longer detects changes to source files (like Markdown files or mkdocs.yml). Consequently, the site does not rebuild, and the browser page does not auto-refresh.

To confirm this was not a container-specific issue, I performed A/B testing with a local Python virtual environment. The same bug occurs when using mkdocs-material==9.6.21 installed via pip, while version 9.6.20 works as expected.

My environment is Windows 11 with WSL2 (Debian 13), with all files and commands being executed within the Linux environment.

Related links

N/A

Reproduction

This is basically just 1:1 the original guide. No special changes required.

9.6.21-mkdocs-serve-no-longer-watches-for-filechanges.zip

Steps to reproduce

  1. Run mkdocs serve --dev-addr=0.0.0.0:7070
  2. Modify index.md
  3. Watch Log

with mkdocs-material==9.6.21

mkdocs serve --dev-addr=0.0.0.0:7070                           
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.22 seconds
INFO    -  [11:38:35] Serving on http://0.0.0.0:7070/

Nothing happens when modifing my index.md

with mkdocs-material==9.6.20

mkdocs serve --dev-addr=0.0.0.0:7070                           
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.21 seconds
INFO    -  [11:37:24] Watching paths for changes: 'docs', 'mkdocs.yml'
INFO    -  [11:37:24] Serving on http://0.0.0.0:7070/
INFO    -  [11:37:28] Detected file changes
INFO    -  Building documentation...
INFO    -  [11:37:28] Reloading browsers
INFO    -  [11:37:30] Detected file changes
INFO    -  Building documentation...
INFO    -  [11:37:30] Reloading browsers

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugupstreamIssue must be taken upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions