sqlmapproject/sqlmap · error · H2Error

proxy CONNECT failed

Error message

proxy CONNECT failed: %s

What it means

_connect_socket status check: the proxy's CONNECT response status line is not 2xx, so the tunnel was refused (407 auth required, 403 forbidden, etc.); the status line itself is embedded in the error.

Solutions

  1. Provide valid proxy credentials (--proxy-cred)
  2. Verify the proxy permits CONNECT to the target host:port
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at lib/request/http2.py:623 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/cc9c4d4bd5c28d34. Report an issue: GitHub.

Appendix: source

Thrown at lib/request/http2.py:623

        request += "\r\n"
        raw.sendall(request.encode("latin-1"))

        # Read only through the CONNECT header terminator. A large recv() can consume
        # bytes from the tunneled TLS handshake that immediately follows the proxy
        # response, and those bytes cannot be pushed back before wrap_socket().
        response = bytearray()
        while not bytes(response).endswith(b"\r\n\r\n"):
            chunk = raw.recv(1)
            if not chunk:
                raise H2Error("proxy closed connection during CONNECT")
            response.extend(chunk)
            if len(response) > 65536:
                raise H2Error("oversized proxy CONNECT response")
        status_line = bytes(response).split(b"\r\n", 1)[0].decode("latin-1", "replace")
        fields = status_line.split(None, 2)
        code = int(fields[1]) if len(fields) >= 2 and fields[1].isdigit() else 0
        if not 200 <= code < 300:
            raise H2Error("proxy CONNECT failed: %s" % status_line)
        return raw
    except Exception:
        try:
            raw.close()
        except Exception:
            pass
        raise


def _make_ssl_context(verify, ssl_context):
    context = ssl_context
    if context is None:
        if verify:
            creator = getattr(ssl, "create_default_context", None)
            if creator is None:
                raise H2Error("certificate verification requires ssl.create_default_context")
            context = creator()
        else:

View on GitHub (pinned to 0a35b20e39)