python
system_error
ai_generated
true
OSError: [Errno 98] 地址已被占用
OSError: [Errno 98] Address already in use
ID: python/starlette-uvicorn-address-in-use
80%修复率
89%置信度
0证据数
2024-02-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
另一个进程(通常是之前的 uvicorn 重载进程)已占用该主机/端口。
English
Another process (often a previous uvicorn reloader) is already bound to the host/port.
解决方案
-
92% 成功率
Find and kill the holder: lsof -i :8000 kill -9 <PID>
-
90% 成功率
Run on a different port: uvicorn app:app --port 8001
无效尝试
常见但无效的做法:
-
85% 失败
Reload doesn't free the port; it spawns another process that fails to bind.
-
90% 失败
More workers compete for the same port and worsen the conflict.