// Redis error reference

NOGROUP: Consumer group does not exist

XREADGROUP or an XGROUP subcommand named a group or a stream that is not there: never created, or the key was deleted or renamed.

Error prefix
NOGROUP
类别
Streams and pub/sub
错误信息
NOGROUP No such key 'orders' or consumer group 'workers' in XREADGROUP with GROUP option

它的意思

NOGROUP is the streams lookup failure: the group name does not exist on that key, or the key itself is gone. On XREADGROUP it means the consumer cannot attach; on XGROUP subcommands such as DELCONSUMER, SETID and DESTROY it means the target group is missing. The reply names both the key and the group, so the miss is unambiguous.

The missing key is the subtle case. Unlike most Redis types, a stream survives as an empty-but-present key once all its entries are deleted, whether or not it has a group, so NOGROUP on a well-known stream name usually means a FLUSHDB, a rename, a different database index, or consumers that started before the group's creator ran.

常见原因

  • The group was never created on this stream: consumers started before the creator did.
  • The stream key was deleted, renamed, or expired, and groups live and die with their key.
  • The consumer and the creator connect to different logical databases or different instances.

Find the cause

TYPE orders
XINFO GROUPS orders
# Is the key there at all, and which groups exist on it?
SELECT 0
# Check the database index too; a mismatch between producer and consumer is a classic

如何修复它

  1. Confirm what exists on the stream, on the database the consumer uses:

    SELECT 0
    TYPE orders
    XINFO GROUPS orders
  2. Recreate the group, choosing the starting id deliberately: 0 replays history, $ starts at new entries:

    XGROUP CREATE orders workers 0
  3. Make creation idempotent at startup so consumers self-heal: run XGROUP CREATE and ignore BUSYGROUP.

Other ways to handle it

If consumers may start against a fresh stream, create groups with MKSTREAM so the key exists even before the first XADD. For anything with strict ordering guarantees, run the group creation as a deploy step rather than inside consumer processes.

安全地复现它

redis-cli DEL orders
redis-cli XADD orders * item widget
redis-cli XREADGROUP GROUP workers consumer-1 COUNT 10 STREAMS orders >
# (error) NOGROUP No such key 'orders' or consumer group 'workers' in XREADGROUP with GROUP option
redis-cli XGROUP CREATE orders workers $
redis-cli XREADGROUP GROUP workers consumer-1 COUNT 10 STREAMS orders >
# (nil) - attached, nothing new yet

问题

The stream exists, why still NOGROUP?

The group name is the miss. Groups are identified by the key and the name together, so a typo in either half produces this error.

Does deleting a stream delete its groups?

Yes. Groups and their pending-entry state belong to the key. DEL or FLUSHDB removes them; recreation starts with an empty pending list.

相关错误

代码和消息文本来自 Redis documentation and source code。浏览完整的 Redis error list 或者 搜索每个数据库错误.

// 错误更少,修复更快

Work on Redis in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Redis and the other databases you use.

本页文字和数据: CC BY 4.0,请注明出处 SQLly (sqlly.app)。 代码和 SQL 片段: MIT. 许可详情 引用的错误消息文本归其数据库厂商所有。