python system_error ai_generated true

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

OSError: [Errno 98] Address already in use

ID: python/flask-debug-reloader-port-in-use

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 95% 成功率
    lsof -ti:5000 | xargs kill -9
  2. 90% 成功率
    app.run(port=5001)

无效尝试

常见但无效的做法:

  1. 80% 失败

    Only avoids the second process; the original is still bound.

  2. 85% 失败

    Does not free the port held by the old process.