this command is not available unless the connection is created with admin-commands enabled

Updated answer for StackExchange.Redis:

var conn = ConnectionMultiplexer.Connect("localhost,allowAdmin=true");

Note also that the object created here should be created once per application and shared as a global singleton, per Marc:

Because the ConnectionMultiplexer does a lot, it is designed to be shared and reused between callers. You should not create a ConnectionMultiplexer per operation. It is fully thread-safe and ready for this usage.


Basically, the dangerous commands that you don't need in routine operations, but which can cause lots of problems if used inappropriately (i.e. the equivalent of drop database in tsql, since your example is FlushDb) are protected by a "yes, I meant to do that..." flag:

using (var conn = new RedisConnection(server, port, -1, password,
          allowAdmin: true)) <==== here

I will improve the error message to make this very clear and explicit.


You can also set this in C# when you're creating your multiplexer - set AllowAdmin = true

    private ConnectionMultiplexer GetConnectionMultiplexer()
    {
        var options = ConfigurationOptions.Parse("localhost:6379");
        options.ConnectRetry = 5;
        options.AllowAdmin = true;
        return ConnectionMultiplexer.Connect(options);
    }