# starlette.exceptions.HTTPException: 404 Not Found

- **ID:** `python/starlette-route-not-found`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

请求的 URL 路径与任何已定义的路由都不匹配，或使用了错误的方法（如 GET 而非 POST）。

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   from starlette.routing import Route
async def homepage(request):
    return Response('Hello')
app = Starlette(routes=[Route('/', homepage)])
   ```
2. **** (85% success)
   ```
   from starlette.routing import Route
async def catch_all(request):
    return JSONResponse({'error': 'not found'}, status_code=404)
app = Starlette(routes=[Route('/{path:path}', catch_all)])
   ```

## Dead Ends

- **** — 根路径可能也没有定义路由，仍然会得到 404。 (50% fail)
- **** — 问题在于路由配置，忽略后无法访问目标资源。 (80% fail)
