NOGROUP error
A stream command named a consumer group or stream that doesn't exist.
Redis returns this error when a stream command uses a consumer group that doesn't exist. The message names both the stream key and the group, because either one can be missing. Commands such as XREADGROUP, XPENDING, XCLAIM, and XGROUP CREATECONSUMER can return it.
NOGROUP No such key 'mystream' or consumer group 'mygroup' in XREADGROUP with GROUP option
In client libraries
| Client library | Exception or error type | Message |
|---|---|---|
| redis-py | ResponseError |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| Jedis | JedisDataException |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| node-redis | SimpleErrorTest with err.message.startsWith('NOGROUP') |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| Lettuce The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()). |
RedisCommandExecutionException |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| go-redis | redis.ErrorTest with redis.HasErrorPrefix(err, "NOGROUP") |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| ioredis | ReplyErrorTest with err.message.startsWith('NOGROUP') |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| StackExchange.Redis NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions. |
RedisServerException |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| Predis | Predis\Response\ServerExceptionTest with $e->getErrorType() === 'NOGROUP' |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
| redis-rb | Redis::CommandError |
NOGROUP No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option (redis://<host>:<port>) |
| redis-rs The sync and async APIs raise the same errors. |
ErrorKind::ExtensionTest with err.code() == Some("NOGROUP") |
"NOGROUP": No such key '<key>' or consumer group '<group>' in XREADGROUP with GROUP option |
Example
> XREADGROUP GROUP mygroup consumer1 STREAMS mystream >
(error) NOGROUP No such key 'mystream' or consumer group 'mygroup' in XREADGROUP with GROUP option
How to fix it
-
The group hasn't been created. Create it with
XGROUP CREATEbefore any consumer reads from it. AddMKSTREAMto create the stream as well, if it doesn't exist yet:> XGROUP CREATE mystream mygroup $ MKSTREAM OKWithout
MKSTREAM, you can't create a group for a stream that doesn't exist:ERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically. -
The stream was deleted. A consumer group is part of its stream. So when the stream key is deleted, or expires, its groups are deleted too. Create the group again.
-
The key or group name is different. Names are case-sensitive. To list a stream's groups, run
XINFO GROUPS.
If several consumers create the group when they start, see BUSYGROUP. For more about consumer groups, see Consumer groups.