python system_error ai_generated true

OSError: [Errno 98] Address already in use

ID: python/starlette-uvicorn-address-in-use

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-02-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

Another process (often a previous uvicorn reloader) is already bound to the host/port.

generic

中文

另一个进程(通常是之前的 uvicorn 重载进程)已占用该主机/端口。

Workarounds

  1. 92% success
    Find and kill the holder:
    lsof -i :8000
    kill -9 <PID>
  2. 90% success
    Run on a different port:
    uvicorn app:app --port 8001

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Reload doesn't free the port; it spawns another process that fails to bind.

  2. 90% fail

    More workers compete for the same port and worsen the conflict.