NationalSecurityAgency/ghidra · error · RuntimeException

Error connecting to ${address}: ${e}

Error message

Error connecting to ${address}: ${e}

What it means

Thrown by ghidraTraceConnect when SocketChannel.open(InetSocketAddress) or the subsequent RmiClient construction/negotiation raises an IOException. The original exception's message is appended so the underlying cause (connection refused, DNS failure, unreachable host) is visible.

Source

Thrown at Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java:152

	public void ghidraTraceConnect(String address) {
		state.requireNoClient();
		String[] addr = address.split(":");
		if (addr.length != 2) {
			throw new RuntimeException("Address must be in the form 'host:port'");
		}
		try {
			SocketChannel channel =
				SocketChannel.open(new InetSocketAddress(addr[0], Integer.parseInt(addr[1])));
			state.client = new RmiClient(channel, "jdi");
			state.client.setRegistry(connector.remoteMethodRegistry);
			state.client.negotiate("Connect");
			Msg.out("Connected to " + state.client.getDescription());
		}
		catch (NumberFormatException e) {
			throw new RuntimeException("Port must be numeric");
		}
		catch (IOException e) {
			throw new RuntimeException("Error connecting to " + address + ": " + e);
		}
	}

	public void ghidraTraceListen(String address) {
		// TODO: UNTESTED
		state.requireNoClient();
		String host = "127.0.0.1";
		int port = 0;
		if (address != null) {
			String[] parts = address.split(":");
			if (parts.length == 1) {
				port = Integer.parseInt(parts[0]);
			}
			else {
				host = parts[0];
				port = Integer.parseInt(parts[1]);
			}
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the Trace RMI server is running and listening on the specified host:port (e.g., check the back-end terminal output for the bound port).
  2. Confirm network reachability: test with a TCP connection or ping to the host.
  3. Check that no firewall is blocking the port and that the host name resolves correctly.
  4. Ensure the JDI agent and Ghidra plugin versions match to avoid negotiate() protocol failures.
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check reachability (best effort)
try (java.net.Socket s = new java.net.Socket()) {
    s.connect(new InetSocketAddress(host, port), 1000);
} catch (IOException e) { /* warn user before ghidraTraceConnect */ }

Try / catch

try { ghidraTraceConnect(address); }
catch (RuntimeException e) {
    if (e.getMessage().startsWith("Error connecting")) { /* surface the cause, offer retry */ }
    else throw e;
}

Prevention

When it happens

Trigger: The Ghidra Trace RMI server is not listening on the given host/port; the host is unreachable or does not resolve; a firewall drops the connection; the RMI handshake (negotiate) fails because the server speaks a different protocol version.

Common situations: The debugger back-end was never started or crashed before Ghidra connected; wrong host/port in the launch offer; the target is on a different network/VPN; a stale acceptor socket; version mismatch between the JDI agent and the Ghidra Trace RMI plugin.

Related errors


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