{"record":{"id":"cf06944eb55d8911","repo":"NationalSecurityAgency/ghidra","slug":"port-must-be-numeric-cf0694","errorCode":null,"errorMessage":"PORT must be numeric","messagePattern":"PORT must be numeric","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":342,"sourceCode":"        else:\n            raise RuntimeError(\"ADDRESS must be PORT or HOST:PORT\")\n    else:\n        raise RuntimeError(\"Usage: ghidra trace listen [ADDRESS]\")\n\n    STATE.require_no_client()\n    try:\n        s = socket.socket()\n        s.bind((host, int(port)))\n        host, port = s.getsockname()\n        s.listen(1)\n        print(f\"Listening at {host}:{port}...\")\n        c, (chost, cport) = s.accept()\n        s.close()\n        print(f\"Connection from {chost}:{cport}\")\n        STATE.client = Client(\n            c, util.LLDB_VERSION.display, methods.REGISTRY)\n    except ValueError:\n        raise RuntimeError(\"PORT must be numeric\")\n\n\n@convert_errors\ndef ghidra_trace_disconnect(debugger: lldb.SBDebugger, command: str,\n                            result: lldb.SBCommandReturnObject,\n                            internal_dict: Dict[str, Any]) -> None:\n    \"\"\"Disconnect LLDB from Ghidra for tracing.\n\n    Usage: ghidra trace disconnect\n    \"\"\"\n\n    args = shlex.split(command)\n    if len(args) != 0:\n        raise RuntimeError(\"Usage: ghidra trace disconnect\")\n\n    STATE.require_client().close()\n    STATE.reset_client()\n","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L324-L360","documentation":"During listen, `s.bind((host, int(port)))` converts the port to an integer; a non-numeric port raises ValueError, re-raised as this message. The message casing ('PORT must be numeric') differs from connect's, so it identifies the listen path specifically.","triggerScenarios":"`ghidra trace listen abc`; `ghidra trace listen host:xyz`; `ghidra trace listen 80.5`.","commonSituations":"Using a service name instead of a numeric port; a stray character in the port token.","solutions":["Use a decimal port: `ghidra trace listen 8080`","Resolve service names to integers before passing them"],"exampleFix":"// before\nghidra trace listen http\n// after\nghidra trace listen 80","handlingStrategy":"validation","validationCode":"def listen_port_is_numeric(token: str) -> bool:\n    parts = token.split(':')\n    port = parts[-1]\n    return port.isdigit()","typeGuard":"def is_int_port(s: str) -> bool:\n    return s.isdigit() and 0 <= int(s) <= 65535","tryCatchPattern":"try:\n    ghidra_trace_listen(debugger, token, result, internal_dict)\nexcept RuntimeError as e:\n    if str(e) == 'PORT must be numeric':\n        # replace service name / non-numeric port with a decimal port\n        ...\n    raise","preventionTips":["Use a decimal integer port for listen","Resolve service names to numbers beforehand","Distinguish this listen error from connect's lower-case 'port must be numeric'"],"tags":["network","ghidra","lldb","cli","validation","connection"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}