redis/node-redis

ErrorReply: WRONGPASS invalid username-password pair or user is disabled.

arunsingh28 opened this issue · 1 comments

Description

I'm encountering a persistent WRONGPASS invalid username-password pair or user is disabled error when trying to connect to a Redis server using the Node.js Redis client. Despite setting the correct password for the default user and verifying it works through the Redis CLI, the connection from the Node.js application continues to fail with the same error. I've followed standard procedures for setting and verifying the password, but the issue remains unresolved.

Note: Authentication works successfully through the Redis CLI, but when attempting to connect via the Node.js application, the WRONGPASS error is thrown.

Node code

import * as redis from "redis";
import { env } from "../../config/env";

const redisClient = redis.createClient({
  url: `${env.MODE === "dev" ? "redis://" : "rediss://"}${env.REDIS_URI}`,
  socket: {
    tls: env.MODE !== "dev",
  },
});

redisClient.on("connect", () => {
  console.log(
    env.MODE === "dev" ? "connected to local redis" : "connected to AWS Valkey caches"
  );
});

redisClient.on("error", (err) => {
  console.log("error connecting to redis", err);
});

export default redisClient;

here I'm firing the server

import App from "./src/app";
import MongoDB from "./src/services/database";
import RedisClient from "./src/services/redis";

import { env } from "./config/env";

const { port } = env;

App.server.listen(port, async () => {
  MongoDB.connectDB();
  await RedisClient.connect();
  console.log(`server listening on port ${port}`);
});

this is my REDIS_URI=default:password@localhost:6379

Node.js Version

18.0.0

Redis Server Version

4.7.0

Node Redis Version

4.7.0

Platform

macOS

Logs

error connecting to redis [ErrorReply: WRONGPASS invalid username-password pair or user is disabled.]