# OSError: [Errno 98] 地址已被占用

- **ID:** `python/starlette-uvicorn-port-in-use`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

另一个进程（通常是之前的 uvicorn 运行）已绑定到目标端口。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   lsof -i :8000 | awk 'NR>1 {print $2}' | xargs kill -9
   ```
2. **** (92% 成功率)
   ```
   uvicorn app:app --port 8001
   ```

## 无效尝试

- **** — The old process keeps the port bound. (85% 失败率)
- **** — Reload does not free the port; the parent still binds it. (90% 失败率)
