sqlmapproject/sqlmap · error · OperationalError

could not connect to '%s:%s' (%s)

Error message

could not connect to '%s:%s' (%s)

What it means

Error "could not connect to '%s:%s' (%s)" thrown in sqlmapproject/sqlmap.

Source

Thrown at extra/dbwire/postgres.py:307

            except (KeyError, binascii.Error, ValueError) as ex:
                raise OperationalError("malformed SCRAM server signature (%s)" % ex)
            server_key = hmac.new(salted, b"Server Key", hashlib.sha256).digest()
            expected = hmac.new(server_key, auth_message.encode("ascii"), hashlib.sha256).digest()
            if not hmac.compare_digest(signature, expected):
                raise OperationalError("SCRAM server signature mismatch (rogue server?)")
        else:
            raise InterfaceError("unsupported authentication request %d" % code)

def _raise_server_error_as_operational(payload):
    message, _ = _error_message(payload)
    raise OperationalError("(remote) %s" % message)

def connect(host=None, port=5432, user=None, password=None, database=None, connect_timeout=None, **kwargs):
    try:
        sock = socket.create_connection((host or "localhost", int(port or 5432)), timeout=connect_timeout)
        keepalive(sock)
    except (socket.error, socket.timeout) as ex:
        raise OperationalError("could not connect to '%s:%s' (%s)" % (host, port, ex))

    params = b""
    for key, value in (("user", user or ""), ("database", database or user or ""), ("client_encoding", "UTF8")):
        params += key.encode("ascii") + b"\x00" + ("%s" % value).encode("utf-8") + b"\x00"
    params += b"\x00"

    try:
        _send(sock, b"", struct.pack("!I", _PROTOCOL_VERSION) + params)  # StartupMessage
        _authenticate(sock, user, password)
        while True:  # drain until ReadyForQuery (ParameterStatus/BackendKeyData/NoticeResponse)
            mtype, payload = _read_message(sock)
            if mtype == b"E":
                _raise_server_error_as_operational(payload)
            if mtype == b"Z":
                break
        handshake_done(sock)
    except Exception:  # any setup failure (DB-API or otherwise) must still close the socket
        try:

View on GitHub (pinned to 0a35b20e39)

When it happens

Trigger: Thrown at extra/dbwire/postgres.py:307 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/32c4ce5f10c79d8b. Report an issue: GitHub.