{"record":{"id":"10457f311d42d951","repo":"eclipse-vertx/vert.x","slug":"port-must-be-65535","errorCode":null,"errorMessage":"port must be <= 65535","messagePattern":"port must be <= 65535","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/NetServerOptions.java","lineNumber":358,"sourceCode":"  }\n\n  /**\n   *\n   * @return the port\n   */\n  public int getPort() {\n    return port;\n  }\n\n  /**\n   * Set the port\n   *\n   * @param port  the port\n   * @return a reference to this, so the API can be used fluently\n   */\n  public NetServerOptions setPort(int port) {\n    if (port > 65535) {\n      throw new IllegalArgumentException(\"port must be <= 65535\");\n    }\n    this.port = port;\n    return this;\n  }\n\n  /**\n   *\n   * @return the host\n   */\n  public String getHost() {\n    return host;\n  }\n\n  /**\n   * Set the host\n   * @param host  the host\n   * @return a reference to this, so the API can be used fluently\n   */","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/NetServerOptions.java#L340-L376","documentation":"NetServerOptions.setPort(int) accepts values up to 65535; anything above throws IllegalArgumentException. Only the upper bound is checked here, so 0 and negative values (often meaning 'random/ephemeral port') are permitted.","triggerScenarios":"Calling setPort(65536) or higher, or a JSON server config whose port exceeds 65535 loaded via fromJson.","commonSituations":"Off-by-one or hexadecimal/decimal confusion producing values like 0x10000; concatenating host:port strings and parsing them back incorrectly; environment-specific configs with copied wrong ports.","solutions":["Use a port in the valid range 0-65535","Validate the configured port before calling: port >= 0 && port <= 65535","Use 0 to let the OS pick an ephemeral port"],"exampleFix":"// before\noptions.setPort(80808); // > 65535\n// after\noptions.setPort(8080);","handlingStrategy":"validation","validationCode":"int port = configuredPort;\nif (port > 65535) {\n  throw new IllegalArgumentException(\"port must be <= 65535\");\n}\noptions.setPort(port);","typeGuard":"boolean isValidPort(int port) { return port >= 0 && port <= 65535; }","tryCatchPattern":null,"preventionTips":["Range-check all ports parsed from strings or config files","Use 0 for an ephemeral OS-assigned port","Beware hex/decimal confusion when copying port literals"],"tags":["validation","port","netserver","config"],"backgroundTag":"value-out-of-range","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}