python network_error ai_generated true

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x...>: Failed to establish a new connection: [Errno 111] Connection refused'))

ID: python/requests-connectionerror-connection-refused

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2025-07-30First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

No service is listening on the specified host and port.

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. Increasing the timeout value 95% fail

    The connection is refused immediately, so timeout does not matter.

  2. Using a different protocol (e.g., HTTPS instead of HTTP) 90% fail

    The port is not open for any protocol.