- Documentation
Cache for Redis
FAQ
Errors and exceptions
Why does it prompt "ERR unknown command 'READONLY'" when connecting Redis via Redission client?
Errors and exceptions
Why does it prompt "ERR unknown command 'READONLY'" when connecting Redis via Redission client?
Why does it prompt "ERR unknown command 'READONLY'" when connecting Redis via Redission client?
Problem phenomenon
When connecting to the Cache for Redis through the Redission client, this error message ERR unknown command 'READONLY' appears. You can view the error message in the following figure.
Possible cause
For the Redission client in Cluster mode, the default value of ReadMode is SLAVE. The Redission client sends the READONLY command to the Redis database by default. However, Cache for Redis does not support the READONLY command currently. When connecting to a Redis instance through the Redission client in Cluster mode, this error ERR unknown command 'READONLY' may appear. For more details about the commands supported by Cache for Redis, refer to Supported commands. Solution
You can refer to any of the following methods to avoid the above errors.
Method 1 (recommended): Set Single mode for the Redission client
The Redission client in Single mode does not use Cluster-related commands (including the READONLY command) to avoid errors such as ERR unknown command 'READONLY'.
Refer to the code below to set Single mode for the Redission client.
Config config = new Config();
config.useSingleServer()
.setAddress("redis://redis-shzlxvk38vs2j****.redis.volces.com:6379")
.setPassword("YourPassword");
RedissonClient redisson = Redisson.create(config);
Method 2: Set ReadMode of Cluster mode to MASTER
If you need to use the Cluster mode of the Redission client as required by business, you can set ReadMode to MASTER (read data from the primary node only). After setting, the Redission client will not send the READONLY command to a Redis database to avoid ERR unknown command 'READONLY'.
Refer to the code below to set the ReadMode of the Redission client in Cluster mode to MASTER.
Config config = new Config();
config.useClusterServers()
.setReadMode(ReadMode.MASTER)
.addNodeAddress("redis://redis-shzlxvk38vs2j****.redis.volces.com:6379")
.setPassword("YourPassword");
RedissonClient redisson = Redisson.create(config);
Last updated: 2025.11.04 21:37:56