redis/jedis · error · IllegalArgumentException
Password not provided in uri.
Error message
Password not provided in uri.
What it means
getPassword(URI) parses the URI's userInfo and expects the form `password` or `user:password`. When userInfo exists but contains no ':' separator (after splitting with limit 2), the library concludes no password portion was provided and throws IllegalArgumentException. A URI with no userInfo at all returns null instead.
Solutions
- Rewrite the URI userInfo to include the password after a colon: `redis://default:YOURPASS@host:6379/`.
- URL-encode special characters in both user and password (e.g. '@' -> %40) so splitting on ':' works as expected.
- If your URI genuinely has no password, don't call getPassword — handle the null case from a null userInfo instead, or use JedisClientConfig setters.
Example fix
// before
URI uri = URI.create("redis://secretpass@localhost:6379/2");
String pass = JedisURIHelper.getPassword(uri); // throws
// after
URI uri = URI.create("redis://default:secretpass@localhost:6379/2");
String pass = JedisURIHelper.getPassword(uri); Defensive patterns
Strategy: validation
Validate before calling
static boolean uriHasPassword(URI uri) {
String ui = uri.getUserInfo();
return ui != null && ui.contains(":");
}
// call before JedisURIHelper.getPassword(uri) Try / catch
try {
String pass = JedisURIHelper.getPassword(uri);
} catch (IllegalArgumentException e) {
// prompt/rebuild URI with user:password form
} Prevention
- Always build redis URIs as redis://user:password@host:port/db.
- URL-encode ':' and '@' inside credentials with URLEncoder.
- Validate the userInfo shape before parsing.
When it happens
Trigger: Passing a URI like `redis://mypassword@host:6379/` (bare token with no colon) to getPassword. Any single-segment userInfo — `redis://user@host`, `redis://token@host` — triggers it, since split(":", 2) yields length 1.
Common situations: Copying connection URIs from providers that URL-encode only the username; ACL-enabled Redis setups where people assume `redis://default@host` carries the password; hand-written URIs missing the `user:password` form.
Related errors
- Failed to evict connections from pool
- Cannot open Redis connection due invalid URI
- Blocking pub/sub operations are not supported on…
- AuthXManager failed to start!
- Unknown protocol
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/acf326e6b80cc2e7.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/util/JedisURIHelper.java:82
return null;
}
/**
* Extracts the password from the given URI.
* <p>
* For details on the URI format and authentication examples, see {@link JedisURIHelper}.
* </p>
* @param uri the URI to extract the password from
* @return the password as a String, or null if {@link URI#getUserInfo()} info is missing
* @throws IllegalArgumentException if {@link URI#getUserInfo()} is provided but does not contain
* a password
*/
public static String getPassword(URI uri) {
String userInfo = uri.getUserInfo();
if (userInfo != null) {
String[] userAndPassword = userInfo.split(":", 2);
if (userAndPassword.length < 2) {
throw new IllegalArgumentException("Password not provided in uri.");
}
return userAndPassword[1];
}
return null;
}
/**
* Checks if the given URI has a database index component.
*
* @param uri the URI to check
* @return true if the URI has a database index component, false otherwise
*/
public static boolean hasDbIndex(URI uri) {
if (uri.getPath() == null || uri.getPath().isEmpty()) {
return false;
}
String[] pathSplit = uri.getPath().split("/", 2);View on GitHub (pinned to 6dac31d4c2)