quarkusio/quarkus · error · RuntimeException

Got unexpected HTTP response code ${r.statusCode()} from ${r

Error message

Got unexpected HTTP response code ${r.statusCode()} from ${requestURI}

What it means

After querying Eureka for instances of the Config Server, EurekaClient requires HTTP 200. Any other status (404, 401, 403, 500, 503...) triggers this RuntimeException naming the code and request URI, meaning the instance lookup against Eureka failed.

Source

Thrown at extensions/spring-cloud-config-client/runtime/src/main/java/io/quarkus/spring/cloud/config/client/runtime/eureka/EurekaClient.java:51

    public JsonObject fetchInstances(String eurekaUrl, String appId) {
        String serviceUrl = UrlUtility.sanitize(eurekaUrl);
        URI serviceURI;
        try {
            serviceURI = new URI(serviceUrl);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Value: '" + serviceUrl, e);
        }
        log.debug("Attempting to discover Spring Cloud Config Server URL for service '" + appId + "' using URL '" + eurekaUrl
                + "'");
        String requestURI = serviceURI.getPath() + "/apps/" + appId;
        log.debug("Attempting to read configuration from '" + requestURI + "'.");
        Uni<JsonObject> uni = webClient
                .get(UrlUtility.getPort(serviceURI), serviceURI.getHost(), requestURI)
                .putHeader("Accept", "application/json")
                .send()
                .map(r -> {
                    if (r.statusCode() != 200) {
                        throw new RuntimeException(
                                "Got unexpected HTTP response code " + r.statusCode() + " from " + requestURI);
                    }
                    String bodyAsString = r.bodyAsString();
                    log.debug("Received response from Spring Cloud Config Server: "
                            + new JsonObject(bodyAsString).encodePrettily());
                    List<JsonObject> upInstances = eurekaResponseMapper.instances(r.bodyAsString())
                            .stream()
                            .filter(i -> UP.equals(i.getString(STATUS)))
                            .toList();

                    return randomEurekaInstanceSelector.select(upInstances);
                });

        return uni.await().atMost(timeout);
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the serviceId exists in Eureka (dashboard shows registered apps; app IDs are uppercase/case-sensitive)
  2. Add Eureka credentials if the registry is secured (configure them in the eureka client config)
  3. Check the requestURI in the message against your Eureka server's actual base path
  4. Check Eureka server logs for 5xx causes and retry after Eureka is healthy

Example fix

# before
quarkus.spring-cloud-config.discovery.service-id=my-config
# after (match Eureka registered app id)
quarkus.spring-cloud-config.discovery.service-id=SPRING-CLOUD-CONFIG-SERVER
Defensive patterns

Strategy: retry

Validate before calling

// verify registration first
HTTP GET {eureka}/eureka/apps/{SERVICE_ID} with Accept: application/json
// require 200 and at least one instance with status UP

Try / catch

try {
    return eurekaClient.fetchInstances(eurekaUrl, appId);
} catch (RuntimeException e) {
    if (e.getMessage().contains("response code 5")) retryWithBackoff(3);
    else throw e; // 404/401 are config problems, not transient
}

Prevention

When it happens

Trigger: GET <eureka>/apps/<serviceId> returns non-200: serviceId not registered (404), Eureka requires credentials (401/403), Eureka server error (500/503).

Common situations: Wrong service-id (Eureka is case-sensitive for app IDs); Eureka secured with basic auth but no credentials configured; wrong context path so /apps/... 404s; Eureka in read-only/self-preserved mode returning 503.

Related errors


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