// 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
Catégorie
Streams and pub/sub
Message d'erreur
NOGROUP No such key 'orders' or consumer group 'workers' in XREADGROUP with GROUP option

Ce que cela signifie

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.

Causes courantes

  • 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

Comment le corriger

  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.

Reproduisez-le en toute sécurité

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

Questions

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.

Erreurs liées

Le code et le texte du message sont issus de Redis documentation and source code. Parcourir la liste complète Redis error list ou Rechercher toutes les erreurs de base de données.

// moins d'erreurs, corrections plus rapides

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.

Texte et données de cette page : CC BY 4.0, en citant SQLly (sqlly.app). Code et extraits SQL : MIT. Détails de la licence Le texte des messages d’erreur cité appartient à l’éditeur de la base de données.