Jump to solution
Verify

The Fix

Upgrade to version 0.22.0 or later.

Based on closed Kludex/uvicorn issue #675 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -104,6 +104,9 @@ Options: is received within this timeout. [default: 5] + --timeout-graceful-shutdown INTEGER + Maximum number of seconds to wait for + graceful shutdown.
repro.py
$ uvicorn <app> --debug INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [84365] using statreload INFO: Started server process [84367] INFO: Waiting for application startup. INFO: Application startup complete. . . . . WARNING: Detected file change in '<file>'. Reloading... INFO: Shutting down INFO: Waiting for background tasks to complete. (CTRL+C to force quit) <--- ??? ^CINFO: Shutting down <--- Ctrl+C
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.22.0 or later.\nWhen NOT to use: This fix should not be used if graceful shutdown is required for ongoing tasks.\n\n

Why This Fix Works in Production

  • Trigger: WARNING: Detected file change in '<file>'. Reloading...
  • Mechanism: The server does not allow immediate shutdown when background tasks are running
  • Why the fix works: Adds a `--timeout-graceful-shutdown` parameter to allow for graceful shutdown configuration from the command line, addressing issue #675. (first fixed release: 0.22.0).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • The server does not allow immediate shutdown when background tasks are running
  • Production symptom (often without a traceback): WARNING: Detected file change in '<file>'. Reloading...

Proof / Evidence

  • GitHub issue: #675
  • Fix PR: https://github.com/kludex/uvicorn/pull/1950
  • First fixed release: 0.22.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.58

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“I need this option. Could you please explain where you change the force_exit, is it in the source code ? Edit : it is in…”
@jjehl · 2021-07-14 · source
“INFO Server running on [http://127.0.0.1:8000]. Press Ctrl+C to stop the server why my serve is not stop giving me reason”
@anishjirel123 · 2022-08-29 · source
“What I said on https://github.com/encode/uvicorn/issues/451#issuecomment-1367828755 also solves the issue here.”
@Kludex · 2022-12-30 · source
“If we set --timeout-graceful-shutdown to 0, then this will be achieved. Let's do that. :+1:”
@Kludex · 2023-03-10 · source

Failure Signature (Search String)

  • WARNING: Detected file change in '<file>'. Reloading...
  • supervisor = ChangeReload(config, target=server.run, sockets=[sock])
Copy-friendly signature
signature.txt
Failure Signature ----------------- WARNING: Detected file change in '<file>'. Reloading... supervisor = ChangeReload(config, target=server.run, sockets=[sock])

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- WARNING: Detected file change in '<file>'. Reloading... supervisor = ChangeReload(config, target=server.run, sockets=[sock])

Minimal Reproduction

repro.py
$ uvicorn <app> --debug INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [84365] using statreload INFO: Started server process [84367] INFO: Waiting for application startup. INFO: Application startup complete. . . . . WARNING: Detected file change in '<file>'. Reloading... INFO: Shutting down INFO: Waiting for background tasks to complete. (CTRL+C to force quit) <--- ??? ^CINFO: Shutting down <--- Ctrl+C

What Broke

Developers experience delays in server reload due to infinite background tasks.

Why It Broke

The server does not allow immediate shutdown when background tasks are running

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

Upgrade to version 0.22.0 or later.

When NOT to use: This fix should not be used if graceful shutdown is required for ongoing tasks.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/kludex/uvicorn/pull/1950

First fixed release: 0.22.0

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if graceful shutdown is required for ongoing tasks.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a stress test that runs high-concurrency workloads and fails on thread dumps / blocked locks.
  • Enable watchdog dumps in prod (faulthandler, thread dump endpoint) to capture deadlocks quickly.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
0.22.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.