python system_error ai_generated true

OSError: [Errno 98] Address already in use

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-05-19First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

A previous Flask dev server (or the reloader child) is still bound to the port, preventing the new process from binding.

generic

中文

之前的 Flask 开发服务器(或重载器子进程)仍占用该端口,导致新进程无法绑定。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

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

  2. 85% fail

    Does not free the port held by the old process.