The Fix
Upgrade to version 0.14.0 or later.
Based on closed Kludex/uvicorn issue #797 · 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%.
@@ -266,6 +266,13 @@ def handle_upgrade(self, event):
msg = "Unsupported upgrade request."
self.logger.warning(msg)
+
+ from uvicorn.protocols.websockets.auto import AutoWebSocketsProtocol
+
❯ uvicorn fapiws:app --reload
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [8960] using watchgod
INFO: Started server process [8970]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:43636 - "GET / HTTP/1.1" 200 OK
INFO: ('127.0.0.1', 43640) - "WebSocket /ws" [accepted]
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 0.14.0 or later.\nWhen NOT to use: This fix is not applicable if the application does not require WebSocket functionality.\n\n
Why This Fix Works in Production
- Trigger: Error during WebSocket handshake: Unexpected response code: 400 (anonymous) @ (index):16
- Mechanism: The new packaging does not install websocket or h11 by default, leading to handshake errors
- Why the fix works: Improves user feedback when no WebSocket library is installed, providing a warning message. (first fixed release: 0.14.0).
- 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
- Shows up under Python 3.8.2 in real deployments (not just unit tests).
- The new packaging does not install websocket or h11 by default, leading to handshake errors
- Surfaces as: Error during WebSocket handshake: Unexpected response code: 400 (anonymous) @ (index):16
Proof / Evidence
- GitHub issue: #797
- Fix PR: https://github.com/kludex/uvicorn/pull/926
- First fixed release: 0.14.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.62
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“ok the new packaging does not install websocket or h11 by default so with a simple pip install uvicorn no ws will be handled”
“> In zsh on macos 10.15.5 i got the error > zsh: no matches found: uvicorn[standard] > > I had to escape the square brackets:…”
“Definitely should provide a gentle message...”
“In zsh on macos 10.15.5 i got the error zsh: no matches found: uvicorn[standard] I had to escape the square brackets: pip3 install uvicorn\[standard\]”
Failure Signature (Search String)
- Error during WebSocket handshake: Unexpected response code: 400 (anonymous) @ (index):16
Error Message
Stack trace
Error Message
-------------
Error during WebSocket handshake: Unexpected response code: 400 (anonymous) @ (index):16
Minimal Reproduction
❯ uvicorn fapiws:app --reload
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [8960] using watchgod
INFO: Started server process [8970]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:43636 - "GET / HTTP/1.1" 200 OK
INFO: ('127.0.0.1', 43640) - "WebSocket /ws" [accepted]
Environment
- Python: 3.8.2
What Broke
WebSocket connections fail with a 400 error during handshake, causing application functionality issues.
Why It Broke
The new packaging does not install websocket or h11 by default, leading to handshake errors
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.14.0 or later.
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/926
First fixed release: 0.14.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the application does not require WebSocket functionality.
Verify Fix
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 TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.14.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.