# requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): 超过最大重试次数 (由NewConnectionError('<urllib3.connection.HTTPConnection object at 0x...>: 无法建立新连接：[Errno 111] 连接被拒绝')引起)

- **ID:** `python/requests-connectionerror-connection-refused`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

指定主机和端口上没有服务在监听。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Start the server or ensure it is running on the correct port** (95% 成功率)
   ```
   Check if the server is running: netstat -tulpn | grep 8080
# Start the server if needed
   ```
2. **Use a different port that the server is actually listening on** (80% 成功率)
   ```
   requests.get('http://localhost:3000')  # if server runs on port 3000
   ```

## 无效尝试

- **Increasing the timeout value** — The connection is refused immediately, so timeout does not matter. (95% 失败率)
- **Using a different protocol (e.g., HTTPS instead of HTTP)** — The port is not open for any protocol. (90% 失败率)
