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
- Verify the bdbsUri points to the Redis Enterprise REST API (correct host/port and scheme)
- Check credentialsSupplier returns valid REST API username/password (or API key)
- Test the URI with curl -u user:pass https://host:port/v1/bdbs and inspect the returned code/body
- 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
- Verify REST URI, port, and scheme before configuring MultiDbClient
- Rotate and test REST API credentials regularly
- Smoke-test the /v1/bdbs endpoint with curl during deployment
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
- No BDB found matching host
- Availability check for
- SSL configuration failed
- No response stream available from server
- protocol must not be null
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)