{"record":{"id":"1e964d75e1992529","repo":"languagetool-org/languagetool","slug":"invalid-port-configuration-found-the-value-for","errorCode":null,"errorMessage":"Invalid port configuration found. The value for '--port' need to be greater than 0 or if set to 0 you need to specify a minPort and maxPort in your properties file (minPort must be lower that maxPort).","messagePattern":"Invalid port configuration found\\. The value for '--port' need to be greater than 0 or if set to 0 you need to specify a minPort and maxPort in your properties file \\(minPort must be lower that maxPort\\)\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/HTTPServer.java","lineNumber":149,"sourceCode":"  \n  private int getPortFromRange(int minPort, int maxPort) throws IOException {\n    if (minPort > 0 && minPort < maxPort) {\n         log.info(\"Try to find a free Port for Server in range {}-{}\", minPort, maxPort);\n         for (int p = minPort; p <= maxPort; p++) {\n           try {\n             log.info(\"Check port {}\", p);\n             ServerSocket serverSocket = new ServerSocket(p);\n             port = serverSocket.getLocalPort();\n             serverSocket.close();\n             log.info(\"Port {} is available.\", p);\n             return p;\n           } catch (IOException ex) {\n             log.debug(\"Port {} is not available.\", p);\n           }\n         }\n         throw new IOException(\"No free port in range (\"+ minPort + \" - \" + maxPort + \") found.\");\n    } else {\n      throw new IOException(\"Invalid port configuration found. \" +\n                            \"The value for '--port' need to be greater than 0 or if set to 0 you need to specify a minPort and maxPort in your properties file (minPort must be lower that maxPort).\");\n    }\n  }\n\n  @Override\n  public void stop() {\n    super.stop();\n    if (executorService != null) {\n      executorService.shutdownNow();\n    }\n  }\n\n  public static void main(String[] args) {\n    if (usageRequested(args)) {\n      System.out.println(\"Usage: \" + HTTPServer.class.getSimpleName() + \" [--config propertyFile] [--port|-p port] [--public]\");\n      System.out.println(\"  --config FILE  a Java property file (one key=value entry per line) with values for:\");\n      printCommonConfigFileOptions();\n      printCommonOptions();","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/HTTPServer.java#L131-L167","documentation":"getPortFromRange validates port configuration: either --port must be > 0, or --port 0 must be combined with minPort and maxPort properties (minPort < maxPort). If neither valid form is found it throws this IOException. It is a configuration validation error, not a network problem.","triggerScenarios":"Starting the server with --port 0 (or port<=0) without defining minPort/maxPort in the properties file, or defining them such that minPort >= maxPort.","commonSituations":"Copy-pasting a properties file that lacks the minPort/maxPort keys while using port=0; typos in property names; setting minPort equal to or above maxPort by mistake.","solutions":["Set --port (or the port property) to a specific positive port number","If dynamic ports are required, add valid minPort and maxPort (minPort < maxPort) to the server properties file","Verify the property file actually passed via --config is the one being read","Check for typos in property keys: exactly 'minPort' and 'maxPort'"],"exampleFix":"# before\njava -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 0 --config server.properties\n# after (server.properties)\nminPort=8081\nmaxPort=8090\n# and keep: --port 0","handlingStrategy":"validation","validationCode":"// validate before launch\nProperties p = loadProps(configFile);\nint port = Integer.parseInt(cmdPort);\nif (port <= 0) {\n  int min = Integer.parseInt(p.getProperty(\"minPort\", \"0\"));\n  int max = Integer.parseInt(p.getProperty(\"maxPort\", \"0\"));\n  if (min <= 0 || max <= 0 || min >= max) throw new IllegalArgumentException(\"Need --port > 0 or valid minPort<maxPort\");\n}","typeGuard":null,"tryCatchPattern":"try { new HTTPServerConfig(args); } catch (IOException e) {\n  if (e.getMessage().startsWith(\"Invalid port configuration\")) { fixPropsOrUseStaticPort(); } else throw e;\n}","preventionTips":["Keep a canonical server.properties template with minPort/maxPort filled","Validate config files in CI before deploying","Prefer explicit static ports in managed environments"],"tags":["configuration","server-startup","cli","java"],"backgroundTag":"invalid-config-value","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}