{"record":{"id":"ab23fa0c08351ab8","repo":"NationalSecurityAgency/ghidra","slug":"server-is-configured-to-run-on-port-change-in","errorCode":null,"errorMessage":"Server is configured to run on port {}: Change in {}","messagePattern":"Server is configured to run on port (.+?): Change in (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":810,"sourceCode":"\t}\n\n\t/**\n\t * Recover the parameter settings from a previously initialized server\n\t * @param configFile is main configuration file: port, adminPassword, hostAuthentication\n\t * @param hbaFile is the connection file\n\t * @throws IOException if the server port is invalid\n\t */\n\tprivate void recoverConfigurationParameters(File configFile, File hbaFile) throws IOException {\n\t\tServerConfig serverConfig = new ServerConfig();\n\t\tserverConfig.addKey(\"port\", \"\");\n\t\tserverConfig.scanConfig(configFile);\n\t\tString value = serverConfig.getValue(\"port\");\n\t\tint scannedPort = 5432;\n\t\tif (value.length() != 0) {\n\t\t\tscannedPort = Integer.parseInt(value);\n\t\t}\n\t\tif (port != -1 && (scannedPort != port)) {\n\t\t\tthrow new IOException(\"Server is configured to run on port \" +\n\t\t\t\tInteger.toString(scannedPort) + \": Change in \" + POSTGRES_CONFIGFILE);\n\t\t}\n\t\tport = scannedPort;\n\n\t\tserverConfig.scanConnect(hbaFile);\n\t\tString localMethod = serverConfig.getLocalAuthentication();\n\t\tif (localMethod == null || localMethod.equals(TRUST_METHOD)) {\n\t\t\tlocalAuthentication = AUTHENTICATION_NONE;\n\t\t}\n\t\telse if (localMethod.equals(PASSWORD_METHOD)) {\n\t\t\tlocalAuthentication = AUTHENTICATION_PASSWORD;\n\t\t}\n\t\telse if (localMethod.equals(CERTIFICATE_METHOD)) {\n\t\t\tlocalAuthentication = AUTHENTICATION_PKI;\n\t\t}\n\t\tString hostMethod = serverConfig.getHostAuthentication();\n\t\tif (hostMethod == null || hostMethod.equals(TRUST_METHOD)) {\n\t\t\thostAuthentication = AUTHENTICATION_NONE;","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L792-L828","documentation":"Thrown by recoverConfigurationParameters when the port read from the existing server's config file (postgresql.conf via ServerConfig) differs from the port specified on the CLI (or implied). The tool refuses to silently override an already-configured server's port.","triggerScenarios":"Running configure/upgrade against an existing server while passing --port that conflicts with the port recorded in the config file (line 810). Only fires when `port != -1` (i.e. a port was explicitly given) and it mismatches the scanned value.","commonSituations":"Migrating/reusing an existing server's data dir with a different port, changing ports after init, or leftover config from a prior instance.","solutions":["Omit --port to accept the port already configured in the server's config file.","Edit POSTGRES_CONFIGFILE to change the recorded port, then re-run.","If you intend a fresh configuration, point at a clean data directory / remove the old config."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Read the configured port from postgresql.conf and compare before passing --port.\nint configured = readPortFromConfig(postgresqlConfFile); // absent => 5432\nif (cliPort != -1 && cliPort != configured) {\n    System.err.println(\"Port \" + cliPort + \" conflicts with configured \" + configured);\n    System.err.println(\"Omit --port or edit \" + POSTGRES_CONFIGFILE);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    launchable.recoverConfigurationParameters(configFile, hbaFile);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Server is configured to run on port\")) {\n        System.err.println(\"Drop --port to accept the configured port, or edit the config file.\");\n    }\n    throw e;\n}","preventionTips":["When operating on an existing server, omit --port to inherit the configured value.","If you must change the port, edit the config file rather than overriding via CLI.","For a fresh start, point at a clean data directory to avoid stale config conflicts."],"tags":["postgresql","configuration","port","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}