# RuntimeError: Working outside of application context.

- **ID:** `python/flask-app-context-import-error`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to access Flask features like current_app or url_for outside of a request or app context.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (100% success)
   ```
   Use with app.app_context(): before accessing current_app or url_for
   ```
2. **** (95% success)
   ```
   If in a CLI command, use app = create_app() and then with app.app_context():
   ```

## Dead Ends

- **** — You need to push an app context manually. (80% fail)
- **** — current_app is a proxy that requires an active context. (100% fail)
