sqlmapproject/sqlmap · error · H2Error
server did not negotiate h2 (ALPN=%r)
Error message
server did not negotiate h2 (ALPN=%r)
What it means
Raised in the HTTP/2 client constructor after the TLS handshake when the ALPN negotiation did not select 'h2'. The endpoint completed TLS but is not offering HTTP/2 on this connection (ALPN result is embedded in the message).
Solutions
- Verify the server supports HTTP/2 over TLS and advertises it via ALPN
- Check that the TLS stack/Python build has ALPN support enabled
- Fall back to an HTTP/1.1 client for this target
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at lib/request/http2.py:943 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/53826602671b3ae0.
Report an issue: GitHub.
Appendix: source
Thrown at lib/request/http2.py:943
self._our_settings_acked = False
context = _make_ssl_context(verify, ssl_context)
raw = _connect_socket(self.host, port, proxy, timeout)
try:
try:
raw.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
except (OSError, socket.error):
pass
self.sock = context.wrap_socket(raw, server_hostname=self.host)
except Exception:
try:
raw.close()
except Exception:
pass
raise
try:
selected = getattr(self.sock, "selected_alpn_protocol", lambda: None)()
if selected != "h2":
raise H2Error("server did not negotiate h2 (ALPN=%r)" % selected)
tls_version = getattr(self.sock, "version", lambda: None)()
if tls_version not in ("TLSv1.2", "TLSv1.3"):
raise H2Error("HTTP/2 requires TLS 1.2 or newer (negotiated %r)" % tls_version)
compression = getattr(self.sock, "compression", lambda: None)()
if compression is not None:
raise H2Error("TLS compression is not permitted for HTTP/2")
self.sock.settimeout(timeout)
settings_payload = struct.pack(
"!HIHIHI",
SETTINGS_ENABLE_PUSH, 0,
SETTINGS_INITIAL_WINDOW_SIZE, LOCAL_INITIAL_WINDOW,
SETTINGS_MAX_HEADER_LIST_SIZE, MAX_HEADER_LIST_SIZE,
)
self.sock.sendall(CONNECTION_PREFACE + encode_frame(SETTINGS, 0, 0, settings_payload))
self.sock.sendall(encode_frame(
WINDOW_UPDATE, 0, 0, struct.pack("!I", LOCAL_INITIAL_WINDOW - DEFAULT_WINDOW)
))
self._receive_initial_settings()View on GitHub (pinned to 0a35b20e39)