node.jsredisnode-redis

Redis: ERR wrong number of arguments for 'auth' command


I'm using redis with nodejs. Version: "redis": "^3.1.2"

When my server connects to redis, I get the following error:

ERR wrong number of arguments for 'auth' command

I'm guessing it has something to do with the URL, which looks like this:

redis://h:<password>@<url>:<port>

My redis is hosted by Heroku and I'm unable to change the URL. And have no idea how can I make it work. Any ideas/solutions much appreciated.


Solution

  • Redis Version < 6.0.0 and node-redis >=3.1.0 , redis://h:<password>@<url>:<port> will not work and throw ERR wrong number of arguments for 'auth' command.

    Solution: redis://:<password>@<url>:<port> works ie: remove username from the URL. Note:- The ":" before the <password>

    This should fix the problem that you are facing.

    For other versions:

    Redis Version < 6.0.0 and node-redis <=3.0.2 , redis://h:<password>@<url>:<port> works.

    Redis Version >= 6.0.0 and node-redis(any version), both redis://<username>:<password>@<url>:<port>(when username in redis ACL is set to custom username) and redis://<password>@<url>:<port> will work.

    The reason is: