The Fix
Upgrade to version 0.11.4 or later.
Based on closed Kludex/uvicorn issue #478 · 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%.
@@ -294,9 +294,11 @@ def run(app, **kwargs):
server = Server(config=config)
- if config.reload and not isinstance(app, str):
+ if (config.reload or config.workers > 1) and not isinstance(app, str):
logger = logging.getLogger("uvicorn.error")
from logging.handlers import DatagramHandler
class Handler(DatagramHandler):
def makePickle(self, record):
# The "uvicorn.access" logger would attach the scope
# with unpickleable object.
record.scope = None
return super().makePickle(record)
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.11.4 or later.\nWhen NOT to use: This fix is not applicable if the application cannot be imported as a string.\n\n
Why This Fix Works in Production
- Trigger: AttributeError: Can't pickle local object 'request_response.<locals>.app'
- Mechanism: The application instance was being passed directly, causing pickling issues in multiprocessing
- Why the fix works: Forces the application to be passed as an import string when using multiple workers, resolving the pickling issue. (first fixed release: 0.11.4).
- 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
- Triggered by an upgrade/regression window: 0.10.1 breaks; 0.11.4 is the first fixed release.
- Shows up under Python 3.6 in real deployments (not just unit tests).
- The application instance was being passed directly, causing pickling issues in multiprocessing
- Surfaces as: AttributeError: Can't pickle local object 'request_response.<locals>.app'
Proof / Evidence
- GitHub issue: #478
- Fix PR: https://github.com/kludex/uvicorn/pull/481
- First fixed release: 0.11.4
- Affected versions: 0.10.1
- 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.66
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for the prompt and detailed response! Changing the app instance parameter to the string style worked fine, and the comments about debug and reload…”
“Also while we're here, you may as well change debug=True to reload=True. https://github.com/encode/uvicorn/issues/480”
“For those hitting the pickling error while using a custom handler, it's due to the app object in the record.scope. Strip it off solves the…”
“Thanks for raising this! Rather than importing the project, you'll need to use the string format for the app argument instead..”
Failure Signature (Search String)
- AttributeError: Can't pickle local object 'request_response.<locals>.app'
Error Message
Stack trace
Error Message
-------------
AttributeError: Can't pickle local object 'request_response.<locals>.app'
Minimal Reproduction
from logging.handlers import DatagramHandler
class Handler(DatagramHandler):
def makePickle(self, record):
# The "uvicorn.access" logger would attach the scope
# with unpickleable object.
record.scope = None
return super().makePickle(record)
Environment
- Python: 3.6
What Broke
Uvicorn fails to start, resulting in application downtime.
Why It Broke
The application instance was being passed directly, causing pickling issues in multiprocessing
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.11.4 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/481
First fixed release: 0.11.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the application cannot be imported as a string.
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
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.10.1 | Broken |
| 0.11.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.