python
system_error
ai_generated
true
OSError: [Errno 98] 地址已被占用
OSError: [Errno 98] Address already in use
ID: python/flask-debug-reloader-port-in-use
80%修复率
87%置信度
0证据数
2024-05-19首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
之前的 Flask 开发服务器(或重载器子进程)仍占用该端口,导致新进程无法绑定。
English
A previous Flask dev server (or the reloader child) is still bound to the port, preventing the new process from binding.
解决方案
-
95% 成功率
lsof -ti:5000 | xargs kill -9
-
90% 成功率
app.run(port=5001)
无效尝试
常见但无效的做法:
-
80% 失败
Only avoids the second process; the original is still bound.
-
85% 失败
Does not free the port held by the old process.