quarkusio/quarkus · error · IllegalStateException

If ${prefix}.host is set, ${prefix}.port must also be set

Error message

If ${prefix}.host is set, ${prefix}.port must also be set

What it means

Thrown by ProxyConfigurationRecorder.build when a proxy block defines a port (and possibly other companion settings) without the corresponding host. The recorder validates each configured proxy prefix: host is the anchor property that activates the proxy, and setting port/user/password/non-proxy-hosts/timeouts without it produces an inconsistent configuration, so the guard aborts startup rather than registering a host-less proxy.

Source

Thrown at extensions/proxy-registry/runtime/src/main/java/io/quarkus/proxy/runtime/ProxyConfigurationRecorder.java:85

            }
            if (config.password().isPresent()) {
                badValues.add("password");
            }
            if (config.nonProxyHosts().isPresent()) {
                badValues.add("non-proxy-hosts");
            }
            if (config.proxyConnectTimeout().isPresent()) {
                badValues.add("proxy-connect-timeout");
            }
            if (badValues.length() > 0) {
                throw new IllegalStateException(
                        "If " + prefix + ".host is not set, then all of " + badValues + " must not be set either");
            }
            return Optional.empty();
        }

        if (config.port().isEmpty()) {
            throw new IllegalStateException("If " + prefix + ".host is set, " + prefix + ".port must also be set");
        }

        if (config.username().isPresent() != config.password().isPresent()) {
            throw new IllegalStateException(prefix + ".username and " + prefix + ".password must be both set or both unset");
        }

        Optional<String> username;
        Optional<String> password;
        if (config.username().isPresent() && config.password().isPresent()) {
            username = config.username();
            password = config.password();
        } else {
            ProxyConfig.ProxyCredentialProviderConfig providerConfig = config.credentialsProvider();
            if (providerConfig.name().isPresent()) {
                CredentialsProvider provider = CredentialsProviderFinder.find(providerConfig.beanName().orElse(null));
                Map<String, String> credentials = provider.getCredentialsAsync(providerConfig.name().get())
                        .await().indefinitely();
                username = Optional.ofNullable(credentials.get(providerConfig.usernameKey()));

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add the port: quarkus.proxy."<name>".port=<port> next to the host property
  2. If no proxy is wanted, remove the host property (and any sibling keys) entirely
  3. Verify env var form is correct, e.g. QUARKS_PROXY__NAME__PORT for named configs (QUARKUS_PROXY__NAME__PORT)

Example fix

// before
quarkus.proxy."x".host=proxy.example.com
// after
quarkus.proxy."x".host=proxy.example.com
quarkus.proxy."x".port=8080
Defensive patterns

Strategy: validation

Validate before calling

if (config.getOptionalValue("quarkus.proxy.\"x\".host", String.class).isPresent()
    && config.getOptionalValue("quarkus.proxy.\"x\".port", Integer.class).isEmpty()) {
    throw new IllegalArgumentException("quarkus.proxy.\"x\".port is required when host is set");
}

Try / catch

try {
    application.start();
} catch (IllegalStateException e) {
    if (e.getMessage() != null && e.getMessage().contains(".port must also be set")) {
        throw new IllegalStateException("Add the matching quarkus.proxy.*.port property", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Setting quarkus.proxy."<name>".host=proxy.example.com (or the default quarkus.proxy.host) without a corresponding .port property at startup.

Common situations: Assuming a default port (8080/3128) is applied automatically; partial config from environment variables where the port var is missing; hand-written blocks omitting port.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/cec0d2d3a5bffdc1. Report an issue: GitHub.