# requests.exceptions.ConnectionError: HTTPConnectionPool(host='api.example.com', port=80): Max retries exceeded

- **ID:** `python/pytest-requests-mock-not-active`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The test uses requests_mock but the mock is not active or does not match the request. This causes the real HTTP request to be attempted, leading to a connection error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (98% success)
   ```
   def test_api(requests_mock):
    requests_mock.get('http://api.example.com/data', json={'key': 'value'})
    response = requests.get('http://api.example.com/data')
    assert response.json() == {'key': 'value'}
   ```
2. **** (95% success)
   ```
   with requests_mock.Mocker() as m:
    m.get('http://api.example.com/data', text='ok')
    requests.get('http://api.example.com/data')
   ```
3. **** (90% success)
   ```
   Print the request URL in the test to ensure it matches the mock's URL.
   ```

## Dead Ends

- **** — This makes tests flaky and dependent on external services. (90% fail)
- **** — Mocks are synchronous; sleeping does not activate them. (95% fail)
- **** — This prevents the error but the test still fails because the request is not mocked. (80% fail)
