Skip to content

Redis ACL username from REDIS_URL is ignored, causing authentication failures #2335

Closed

Description

@MrSnakeDoc

Description

When using a Redis/Valkey instance configured with ACLs (Redis >= 6), the username provided in REDIS_URL is ignored.

The documentation states that the expected format is:

redis://username:password@host:port/db-number

However, parseRedisUrl() only extracts the password and never reads the username.

Current implementation:

export function parseRedisUrl(redisUrl: string): RedisConfig {
  // format - redis[s]://[[username][:password]@][host][:port][/db-number][?family=4|6]
  const url = new URL(redisUrl);
  const { hostname, port, password, pathname, searchParams } = url;

  ...

  return { host: hostname, port: portInt, password, db, family };
}

As a result, the username is silently discarded.

Impact

Applications using Redis ACLs cannot authenticate correctly.

For example, with:

REDIS_URL=redis://myuser:mypassword@redis:6379

the resulting configuration only contains:

{
  host,
  port,
  password,
  db,
  family,
}

When a new Redis client is later created, only the password is passed:

new Redis({
  host,
  port,
  password,
  db,
  family,
})

instead of:

new Redis({
  host,
  port,
  username,
  password,
  db,
  family,
})

This causes ioredis to authenticate against the default user instead of the intended ACL user.

Typical runtime errors look like:

This Redis server's `default` user does not require a password, but a password was supplied
ReplyError: NOAUTH Authentication required.

Additional observations

While investigating, I also noticed that several places rebuild Redis client configurations manually and only pass the password.

For example:

  • ThrottleModule
  • the collaboration/Hocuspocus Redis synchronization code

Both instantiate Redis clients without providing a username.

Even if parseRedisUrl() is fixed, these locations will also need to pass the parsed username to the Redis client.

Expected behavior

  • parseRedisUrl() should extract url.username.
  • RedisConfig should expose a username field.
  • Every Redis client should pass both username and password when constructing the connection.

This would make the implementation match the documented REDIS_URL format and allow authentication against Redis ACL users.

Activity

  1. Shivamkumar31 commented on Jul 10, 2026

    @Shivamkumar31

    I'd like to work on this, can you assign it to me?'

  2. Philipinho commented on Aug 26, 2026

    @Philipinho
    Member

    Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions