redis/jedis · error · IOException

Unexpected response code

Error message

Unexpected response code '${code}' for getBdbs: '${responseBody}' from '${bdbsUri}'

What it means

RedisRestAPI.getBdbs() performs a GET against the Redis Enterprise REST API /bdbs endpoint. Any HTTP status other than 200 results in IOException "Unexpected response code '<code>' for getBdbs: '<body>' from '<uri>'". The message includes the status code, response body, and REST URI to ease diagnosis.

Solutions

  1. Verify the bdbsUri points to the Redis Enterprise REST API (correct host/port and scheme)
  2. Check credentialsSupplier returns valid REST API username/password (or API key)
  3. Test the URI with curl -u user:pass https://host:port/v1/bdbs and inspect the returned code/body
  4. If 401/403, fix credentials; if 5xx, check cluster health

Example fix

// before
RedisRestAPI api = new RedisRestAPI("https://cluster.example.com:8080", ...); // wrong port
// after
RedisRestAPI api = new RedisRestAPI("https://cluster.example.com:9443", ...); // REST API port
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check: HttpURLConnection c = (HttpURLConnection) new URL(bdbsUri).openConnection(); // verify reachable + credentials valid before client build

Try / catch

try { BdbsInfo info = restApi.bdbs(); } catch (IOException e) { /* parse code/body from message; correct URI/credentials and retry */ }

Prevention

When it happens

Trigger: REST API returns 401/403 (bad credentials), 404 (wrong base URL/port), 5xx (cluster issues), or a proxy error page while calling getBdbs (used by MultiDbClient's database discovery).

Common situations: Wrong management URI or port (not the 8070/9443 REST port); expired or wrong username/password credentials; TLS verification mismatch; cluster nodes down.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/a9dc7d32816d7fa3. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/mcf/RedisRestAPI.java:78

    this.endpoint = endpoint;
    this.credentialsSupplier = credentialsSupplier;
    this.timeoutMs = timeoutMs;
    this.sslOptions = sslOptions;
  }

  public List<RedisRestAPI.BdbInfo> getBdbs() throws IOException {
    if (bdbsUri == null) {
      bdbsUri = String.format(BDBS_URL, endpoint.getHost(), endpoint.getPort());
    }

    HttpURLConnection conn = null;
    try {
      conn = createConnection(bdbsUri, "GET", credentialsSupplier.get());
      conn.setRequestProperty("Accept", "application/json");
      int code = conn.getResponseCode();
      String responseBody = readResponse(conn);
      if (code != 200) {
        throw new IOException("Unexpected response code '" + code + "' for getBdbs: '"
            + responseBody + "' from '" + bdbsUri + "'");
      }
      return parseBdbInfoFromResponse(responseBody);
    } finally {
      if (conn != null) conn.disconnect();
    }
  }

  public boolean checkBdbAvailability(String uid, boolean lagAware) throws IOException {
    return checkBdbAvailability(uid, lagAware, null);
  }

  public boolean checkBdbAvailability(String uid, boolean extendedCheckEnabled,
      Long availabilityLagToleranceMs) throws IOException {
    String availabilityUri;
    if (extendedCheckEnabled) {
      // Use extended check with lag validation
      availabilityUri = String.format(LAGAWARE_AVAILABILITY_URL, endpoint.getHost(),

View on GitHub (pinned to 6dac31d4c2)