# OSError: [Errno 98] Address already in use
  during setup of tests/test_http.py::test_fetch
  port 8080 is already bound

- **ID:** `python/pytest-httpserver-port-in-use`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A previous test run or another process is still holding the port. Common with pytest-httpserver, responses, or a local dev server started in a session-scoped fixture that was not torn down.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |

## Workarounds

1. **** (97% success)
   ```
   from pytest_httpserver import HTTPServer

def test_fetch(httpserver: HTTPServer):
    httpserver.expect_request('/api').respond_with_json({'ok': True})
    url = httpserver.url_for('/api')  # uses assigned port
    assert fetch(url) == {'ok': True}
   ```
2. **** (95% success)
   ```
   @pytest.fixture(scope='session')
def server():
    srv = HTTPServer()
    srv.start()
    yield srv
    srv.stop()  # critical
   ```

## Dead Ends

- **** — Next run someone else uses 8081; whack-a-mole with no root fix and CI containers may have different free ports. (80% fail)
- **** — The port stays bound between retries; retries fail immediately. (90% fail)
