How do you specify the password for the Redis server with StackExchange.Redis? I am guessing you add it to the configuration string which is passed to the Connect method. I can't seem to find the format in which it needs to be specified.
I will add a full list of the key/value pairs to the configuration docs tomorrow. Short version is: probably "foo,password=value". Longer version is: use ConfigurationOptions
and set .Password
. The document shows you how to switch between the two layouts.
This is the way I got it working (note that simply adding the password like "localhost:6379,password=value"
didn't work for me - it needs to be set in the options):
var options = ConfigurationOptions.Parse("localhost:6379"); // host1:port1, host2:port2, ...
options.Password = "yourPassword";
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(options);
IDatabase conn = redis.GetDatabase();
Assuming that you're running it via:
docker run -d -p 6379:6379 --name yourRedisInstance redis --requirepass yourPassword
If the docker image wasn't run with a password, simply remove the line options.Password = "yourPassword";
In that case, everyone can access the Redis service without a password (which you should not do if you have data in the cache that needs to be protected).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With