python · Python
The message
OSError: [Errno 98] Address already in use
What it means
The bind failed because another process already holds that port. Either the previous server did not fully die, an auto-reloader started two copies, or a Docker container is already publishing the same port. lsof -i :8000 gives you the PID that holds it so you can clear just that one — read the process name before you kill -9 anything. The errno differs per system: Linux prints 98 here, macOS prints 48.
The fix
lsof -i :8000- Printed by
- python
- Python
- 18
A Python traceback splits the answer in two — the last line says what went wrong, the frames above it say where — so reading only the last line gives you the name and loses the place, and for the value-is-missing errors such as NoneType and KeyError the cause almost always sits in a frame above the one that crashed.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “OSError: [Errno 98] Address already in use” mean?
The bind failed because another process already holds that port. Either the previous server did not fully die, an auto-reloader started two copies, or a Docker container is already publishing the same port. lsof -i :8000 gives you the PID that holds it so you can clear just that one — read the process name before you kill -9 anything. The errno differs per system: Linux prints 98 here, macOS prints 48.
Q. How do I fix it?
lsof -i :8000 — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
python. It sits under Python, and the message runs to 7 words.