{"record":{"id":"cecec09d2852c1bb","repo":"languagetool-org/languagetool","slug":"https-server-start-failed","errorCode":null,"errorMessage":"https_server_start_failed","messagePattern":"https_server_start_failed","errorType":"exception","errorClass":"PortBindingException","httpStatus":null,"severity":"critical","filePath":"languagetool-server/src/main/java/org/languagetool/server/HTTPSServer.java","lineNumber":81,"sourceCode":"      if (host == null) {\n        server = HttpsServer.create(new InetSocketAddress(port), 0);\n      } else {\n        server = HttpsServer.create(new InetSocketAddress(host, port), 0);\n      }\n      SSLContext sslContext = getSslContext(config.getKeystore(), config.getKeyStorePassword());\n      HttpsConfigurator configurator = getConfigurator(sslContext);\n      ((HttpsServer)server).setHttpsConfigurator(configurator);\n      RequestLimiter limiter = getRequestLimiterOrNull(config);\n      ErrorRequestLimiter errorLimiter = getErrorRequestLimiterOrNull(config);\n      executorService = getExecutorService(config);\n      BlockingQueue<Runnable> workQueue = executorService.getQueue();\n      httpHandler = new LanguageToolHttpHandler(config, allowedIps, runInternally, limiter, errorLimiter, workQueue, this);\n      server.createContext(\"/\", httpHandler);\n      server.setExecutor(executorService);\n    } catch (BindException e) {\n      ResourceBundle messages = JLanguageTool.getMessageBundle();\n      String message = Tools.i18n(messages, \"https_server_start_failed\", host, Integer.toString(port));\n      throw new PortBindingException(message, e);\n    } catch (Exception e) {\n      ResourceBundle messages = JLanguageTool.getMessageBundle();\n      String message = Tools.i18n(messages, \"https_server_start_failed_unknown_reason\", host, Integer.toString(port));\n      throw new RuntimeException(message, e);\n    }\n  }\n\n  private SSLContext getSslContext(File keyStoreFile, String passPhrase) {\n    try (FileInputStream keyStoreStream = new FileInputStream(keyStoreFile)) {\n      KeyStore keystore = KeyStore.getInstance(\"JKS\");\n      keystore.load(keyStoreStream, passPhrase.toCharArray());\n      KeyManagerFactory kmf = KeyManagerFactory.getInstance(\"SunX509\");\n      kmf.init(keystore, passPhrase.toCharArray());\n      TrustManagerFactory tmf = TrustManagerFactory.getInstance(\"SunX509\");\n      tmf.init(keystore);\n      SSLContext sslContext = SSLContext.getInstance(\"TLS\");\n      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);\n      return sslContext;","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/HTTPSServer.java#L63-L99","documentation":"When HTTPSServer fails to bind its HTTPS listener to host:port because the port is already in use (java.net.BindException), it wraps the failure in a PortBindingException with the localized 'https_server_start_failed' message. It means the server could not start listening on the requested address.","triggerScenarios":"Starting the HTTPS server on a port already occupied by another process (or another running LT instance); binding to an address not available on the machine.","commonSituations":"Two LT server instances started simultaneously; port already taken by nginx/apache or a leftover JVM; running in a container where the mapped port is claimed.","solutions":["Find the process using the port (e.g. ss -ltnp | grep <port> or lsof -i :<port>) and stop it.","Choose a different port via the server config (port settings).","Kill a stale previous LanguageTool server instance.","In containers, fix the host port mapping or use the port-range option to auto-pick a free port."],"exampleFix":"// before\n# server.properties: port 8081 already used\nport = 8081\n// after\n# stop the conflicting process first, or pick a free port\nport = 8082","handlingStrategy":"try-catch","validationCode":"// check port availability before startup\ntry (ServerSocket s = new ServerSocket()) {\n  s.bind(new InetSocketAddress(host, port));\n} catch (IOException e) {\n  throw new IllegalStateException(\"Port \" + port + \" already in use\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  httpsServer = new HTTPSServer(config, false, host, allowedIps);\n} catch (PortBindingException e) {\n  log.error(\"HTTPS port {} in use, pick another port\", config.getPort(), e);\n  System.exit(1);\n}","preventionTips":["Check port availability in deployment scripts before launch","Use distinct ports per service; avoid hardcoding in shared hosts","In containers, verify port mappings don't collide","Use the server's port-range option to auto-select a free port"],"tags":["port-binding","network","https","server-startup"],"backgroundTag":"address-already-in-use","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}