# httpx.ConnectError: [Errno -2] Name or service not known

- **ID:** `python/pytest-httpx-mock-interface-mismatch`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

respx/httpx mock router wasn't registered for the URL being requested, or the client instance was created before the mock was installed, so the real network call is attempted.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.20.x | active | — | — |
| 0.21.x | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   import httpx, respx

@respx.mock
def test_get():
    respx.get('https://api.example.com/users/1').mock(
        return_value=httpx.Response(200, json={'id': 1})
    )
    with httpx.Client() as c:
        r = c.get('https://api.example.com/users/1')
    assert r.json()['id'] == 1
   ```
2. **** (90% success)
   ```
   with respx.mock(assert_all_called=True) as router:
    router.get('https://api.example.com/').mock(return_value=httpx.Response(200))
    run_code()
   ```

## Dead Ends

- **** — Over-broad; hides typos in URLs and returns the same mock for every request, defeating per-endpoint assertions. (70% fail)
- **** — Bypasses proxies but doesn't prevent the real DNS lookup; the error persists. (80% fail)
