Fix: “ERR wrong number of arguments for ‘sismember’ command” in Redis

If you’re getting an error that reads “ERR wrong number of arguments for ‘sismember’ command” in Redis, it’s because you’re calling the SISMEMBER command with the wrong number of arguments.

To fix this issue, make sure you’re passing the correct number of arguments. At the time of writing, the correct number of arguments for this command is two.

Example of Error

Here’s an example of code that produces the above error:

SISMEMBER animals

Result:

(error) ERR wrong number of arguments for 'sismember' command

In this case, I only passed one argument, but I should have passed two.

We get the same error when we pass too many arguments:

SISMEMBER animals Cat Dog

Result:

(error) ERR wrong number of arguments for 'sismember' command

Solution

To fix the issue, simply pass the correct number of arguments.

Example:

SISMEMBER animals Cat

Result:

(integer) 1

Here, I provided the correct number of arguments and we got the desired result without error.

At the time of writing, SISMEMBER accepts two arguments. The first argument specifies the key, the second argument specifies the value/member to search for. See the Redis documentation to check the latest specification for this command.