18

I am using jedis 2.8.0 and getting following exception:

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
        at redis.clients.jedis.Protocol.processError(Protocol.java:123)
        at redis.clients.jedis.Protocol.process(Protocol.java:157)
        at redis.clients.jedis.Protocol.read(Protocol.java:211)
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
        at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:196)
        at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2049)
        at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:89)
        at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:458)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
        at redis.clients.util.Pool.getResource(Pool.java:49)
        ... 4 more

Following is the api I am using:

jedisPool = new JedisPool(jedisPoolConfig, host, port, IDLE_CONNECTION_TIMEOUT, authSecret); 

Notes:

  1. I am able to successfully send commands to redis using the exact same password using the redis-cli -a option.
  2. I also printed the password in the logs to see if I am sending wrong password, but the password passed to JedisPool is proper.
  3. I also tried to "redis-cli monitor" calls on redis but I dont see any AUTH request.
sazzad
  • 5,740
  • 6
  • 25
  • 42
user1619355
  • 429
  • 1
  • 4
  • 17

2 Answers2

21

There is no password set in your Redis instance. Password sent with redis-cli -a is just being ignored.

Now, you may set the password in redis instance. To do so, edit redis configuration file, set requirepass option and restart redis instance.

Or, just ignore password option while communicating with redis. E.g.

jedisPool = new JedisPool(jedisPoolConfig, host, port, IDLE_CONNECTION_TIMEOUT);
sazzad
  • 5,740
  • 6
  • 25
  • 42
3

This will might work if you don't want to set the password. enter image description here

spring.redis.host=127.0.0.1 
spring.redis.port=6379 
spring.redis.password=

Leave the password field as blank.

OR

Use the requirepass a password option

redis 127.0.0.1:6379> AUTH PASSWORD

(error) ERR Client sent AUTH, but no password is set.

redis 127.0.0.1:6379> CONFIG SET requirepass "mypass"

OK

redis 127.0.0.1:6379> AUTH mypass

OK

Shubham
  • 91
  • 3
  • Didn't work for me using Jedis. Leaving the password empty still caused the same exception. What worked for me is just configuring the password using requirepass in the redis.conf – Tom Mar 08 '21 at 13:40