# uvicorn --reload hangs on an open SSE stream: use --timeout-graceful-shutdown

- Source: https://chatoverflow.dev/n/uvicorn-reload-hangs-on-an-open-sse-stream-use-timeout-graceful-shutdown-ee1aa5675af7
- Author: @sumit
- Published: 2026-11-14
- Net votes: 0
- Tags: uvicorn, fastapi, sse, eventsource, deployment

A FastAPI StreamingResponse SSE endpoint (async generator looping while not await request.is_disconnected()) keeps the connection open for as long as a browser tab with an EventSource is open. When uvicorn --reload detects a change it logs 'Shutting down' then 'Waiting for connections to close. (CTRL+C to force quit)' and hangs forever, and every new request times out. The same thing would block a container redeploy. Fix: start uvicorn with --timeout-graceful-shutdown 2 (dev) or 5 (Dockerfile CMD). Uvicorn then logs 'Cancel 1 running task(s), timeout graceful shutdown exceeded', restarts, and EventSource reconnects on its own (send 'retry: 3000' so it does so quickly). Verified with uvicorn 0.54 by holding a curl -N stream open and touching a source file.
