{"record":{"id":"6c6386fb12b0e1aa","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-connect-to-server","errorCode":null,"errorMessage":"Unable to connect to server","messagePattern":"Unable to connect to server","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"critical","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java","lineNumber":141,"sourceCode":"\t\treturn exceedCount;\n\t}\n\n\t/**\n\t * @return true if similarity and significance thresholds have been set\n\t */\n\tpublic boolean isConfigured() {\n\t\treturn (scorer.simThreshold > 0.0);\n\t}\n\n\t/**\n\t * Make sure the database has an active connection. Query for basic\n\t * information and inform the scorer of settings\n\t * @return information from the database\n\t * @throws LSHException if something is wrong with the connection\n\t */\n\tprivate DatabaseInformation pullConnectionInfo() throws LSHException {\n\t\tif (!database.initialize()) {\n\t\t\tthrow new LSHException(\"Unable to connect to server\");\n\t\t}\n\t\tQueryInfo query = new QueryInfo();\n\t\tResponseInfo response = query.execute(database);\n\t\tif (response == null) {\n\t\t\tthrow new LSHException(database.getLastError().message);\n\t\t}\n\t\tvectorFactory = database.getLSHVectorFactory();\n\t\treturn response.info;\n\t}\n\n\t/**\n\t * Look up a full ExecutableRecord in the database given an md5\n\t * @param md5 is the md5 String\n\t * @return the corresponding ExecutableRecord\n\t * @throws LSHException if there are problems accessing the database\n\t *    or the executable doesn't exist\n\t */\n\tprivate ExecutableRecord lookupExecutable(String md5) throws LSHException {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java#L123-L159","documentation":"Thrown by ExecutableComparison.pullConnectionInfo when database.initialize() returns false, meaning the BSim FunctionDatabase could not establish or validate a connection to the backing SQL/Elasticsearch server. This is the first connectivity gate before any query is issued.","triggerScenarios":"Calling ExecutableComparison scoring/comparison methods when the database server is unreachable, credentials are wrong, the target database doesn't exist, or the connection URL is malformed. initialize() returns false on any connection failure.","commonSituations":"Wrong BSim URL (host/port/dbname); PostgreSQL or Elasticsearch server down; firewall blocking the port; expired credentials; SSL/TLS mismatch; database not yet created.","solutions":["Verify the BSim server URL, host, port, and database name are correct and the server is running.","Check network connectivity (telnet/ping to the host:port) and credentials.","Ensure the database has been created (BSim DBs must be created before connection).","Inspect db.getLastError() after initialize() returns false for the specific cause."],"exampleFix":"// before\nExecutableComparison cmp = new ExecutableComparison(db);\ncmp.addAllExecutables(0); // throws if not initialized\n// after\nif (!db.initialize()) {\n    BSimError err = db.getLastError();\n    throw new RuntimeException(\"BSim connection failed: \" + (err != null ? err.message : \"unknown\"), err);\n}","handlingStrategy":"validation","validationCode":"if (!database.initialize()) {\n    BSimError err = database.getLastError();\n    // surface err.message to the user; do not proceed with ExecutableComparison\n    return;\n}","typeGuard":null,"tryCatchPattern":"catch (LSHException e) { if (e.getMessage().contains(\"Unable to connect\")) { /* check server, credentials, URL; retry after fix */ } }","preventionTips":["Always call database.initialize() and check its boolean return before using ExecutableComparison.","Validate the BSim URL format and server reachability at application startup.","Inspect getLastError() for the root cause rather than retrying blindly."],"tags":["bsim","network","database","connection"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}