quarkusio/quarkus · error · IllegalArgumentException
Invalid port number
Error message
Invalid port number
What it means
Thrown by QuarkusRestClientBuilder.proxyAddress when the port is outside the valid range 1-65535. Proxy ports must be a valid TCP port, so zero, negative values and values above 65535 are rejected with IllegalArgumentException.
Source
Thrown at extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java:181
public RestClientBuilder queryParamStyle(QueryParamStyle queryParamStyle) {
this.queryParamStyle = queryParamStyle;
return this;
}
@Override
public RestClientBuilder header(final String name, final Object value) {
headers.add(Objects.requireNonNull(name, "A header name is required."),
Objects.requireNonNull(value, "Value for header is required."));
return this;
}
@Override
public RestClientBuilder proxyAddress(String host, int port) {
if (host == null) {
throw new IllegalArgumentException("proxyHost must not be null");
}
if (port <= 0 || port > 65535) {
throw new IllegalArgumentException("Invalid port number");
}
this.proxyHost = host;
this.proxyPort = port;
return this;
}
@Override
public RestClientBuilder baseUrl(URL url) {
try {
baseURI = url.toURI();
return this;
} catch (URISyntaxException e) {
throw new RuntimeException(e.getMessage());
}
}
@Override
public RestClientBuilder baseUri(URI uri) {View on GitHub (pinned to e1c734241f)
Solutions
- Pass a valid port in the 1-65535 range (typically 80, 443, 3128, 8080, etc.)
- Fix the proxy-address config value to a valid host:port pair
- Do not use sentinel values like 0 or -1 to disable the proxy — simply don't call proxyAddress
Example fix
// before
builder.proxyAddress("proxy.corp", 80800); // IllegalArgumentException: Invalid port number
// after
builder.proxyAddress("proxy.corp", 8080); Defensive patterns
Strategy: validation
Validate before calling
if (port < 1 || port > 65535) {
throw new IllegalArgumentException("Proxy port out of range: " + port);
} Type guard
static boolean isValidPort(int p) { return p > 0 && p <= 65535; } Try / catch
try {
builder.proxyAddress(host, port);
} catch (IllegalArgumentException e) {
if (e.getMessage().equals("Invalid port number")) {
log.error("Bad proxy port: {}", port);
}
throw e;
} Prevention
- Never use 0 or -1 as a 'disabled' sentinel port — omit the proxyAddress call instead
- Parse proxy ports with Integer.parseInt and range-check before use
- Validate proxy-address host:port config values at startup
When it happens
Trigger: Calling builder.proxyAddress(host, 0), a negative port, or a port parsed from a truncated/garbled config value; port > 65535 from an int overflow of a concatenated string; passing -1 as a 'no proxy' sentinel.
Common situations: Using -1 or 0 as a default 'unset' port constant; config property proxy-address missing the port part so the parsed default leaks through; typos like 80800.
Related errors
- proxyHost must not be null
- Invalid proxy string. Expected <hostname>:<port>, found '${p
- Invalid proxy setting. The port is not a number in '${proxy}
- Unknown JAR package type '${value}'
- Unable to resolve locale: ${value}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/d6441b08459df405.
Report an issue: GitHub.