NationalSecurityAgency/ghidra · error · RuntimeError

Not connected

Error message

Not connected

What it means

Raised by State.require_client when STATE.client is None. The client is the socket connection to Ghidra's trace-rpc service, established by ghidra_trace_connect or ghidra_trace_listen. Any command that needs the trace-rpc connection will hit this guard if connect has not been called or was reset.

Source

Thrown at Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py:118

    def require_mm(self) -> arch.DefaultMemoryMapper:
        if self.memory_mapper is None:
            raise RuntimeError("No memory mapper")
        return self.memory_mapper

    def require_rm(self) -> arch.DefaultRegisterMapper:
        if self.register_mapper is None:
            raise RuntimeError("No register mapper")
        return self.register_mapper


class State(object):

    def __init__(self) -> None:
        self.reset_client()

    def require_client(self) -> Client:
        if self.client is None:
            raise RuntimeError("Not connected")
        return self.client

    def require_no_client(self) -> None:
        if self.client != None:
            raise RuntimeError("Already connected")

    def reset_client(self) -> None:
        self.client: Optional[Client] = None
        self.reset_trace()

    def require_trace(self) -> Trace[Extra]:
        if self.trace is None:
            raise RuntimeError("No trace active")
        return self.trace

    def require_no_trace(self) -> None:
        if self.trace != None:
            raise RuntimeError("Trace already started")

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run 'ghidra_trace_connect <host:port>' or 'ghidra_trace_listen' before issuing trace commands.
  2. After a disconnect, re-connect before the next operation.
  3. Check STATE.client is not None before calling require_client-dependent commands.

Example fix

# before: commands without connect
STATE.require_client()  # client is None -> RuntimeError

# after: connect first
ghidra_trace_connect('127.0.0.1:12345')
client = STATE.require_client()
Defensive patterns

Strategy: validation

Validate before calling

if STATE.client is None:
    raise RuntimeError("Not connected; run 'ghidra trace connect <host:port>' first")

Type guard

def is_connected() -> bool:
    return STATE.client is not None

Try / catch

try:
    client = STATE.require_client()
except RuntimeError:
    ghidra_trace_connect('127.0.0.1:12345')
    client = STATE.require_client()

Prevention

When it happens

Trigger: A command calls STATE.require_client() before ghidra_trace_connect or ghidra_trace_listen has established the connection. This also fires after ghidra_trace_disconnect resets the client.

Common situations: User issued trace commands before connecting to Ghidra. The connection was dropped or disconnected and not re-established. ghidra_trace_disconnect was called and then commands were issued without re-connecting.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/19bb4b1e3173ad6c. Report an issue: GitHub.