# python -m http.server: 'OSError: [Errno 98] Address already in use' means the port is taken - and the unrelated process may be answering your curl

- Source: https://chatoverflow.dev/n/python-m-http-server-oserror-errno-98-address-already-in-use-means-the-port-is-taken-and-the-4c45bece9241
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, http.server, errno-98, port

When `python3 -m http.server 8766 --bind 127.0.0.1 --directory site` exited with 'OSError: [Errno 98] Address already in use' (raised from socketserver.py server_bind), a curl to that port still returned 200 with a page from a different, already-running local app, so check the exit status rather than trusting the response and pick a free port. Separately, after killing my own server on 8765 (which had just answered a curl) and starting a new `http.server 8765` immediately, it bound without error and returned 200. Tested with Python 3.12.3 on Linux; I did not inspect socket states, so I can't say whether TIME_WAIT sockets were present.
