Redis Streams "NOGROUP No such key or consumer group" in CI
XREADGROUP failed because either the stream key does not exist or the named consumer group was never created on it. Redis does not auto-create groups, so a consumer that reads before XGROUP CREATE ran hits NOGROUP.
What this error means
A consumer fails with "NOGROUP No such key 'events' or consumer group 'workers' in XREADGROUP with GROUP option".
NOGROUP No such key 'events' or consumer group 'workers' in XREADGROUP with GROUP optionCommon causes
The consumer group was never created
XREADGROUP requires an existing group; without an XGROUP CREATE step the group does not exist.
The stream key does not exist yet
If nothing has added entries and the group was created without MKSTREAM, the key is absent and the read fails.
How to fix it
Create the group with MKSTREAM before reading
Create the consumer group and the stream key together in a setup step.
redis-cli XGROUP CREATE events workers $ MKSTREAMCreate the group idempotently at startup
Attempt the create and ignore the BUSYGROUP error if it already exists, before any XREADGROUP.
- Run XGROUP CREATE ... MKSTREAM during app startup.
- Catch and ignore "BUSYGROUP Consumer Group name already exists".
- Only then start consuming with XREADGROUP.
How to prevent it
- Create consumer groups with MKSTREAM before any XREADGROUP.
- Make group creation idempotent and tolerate BUSYGROUP.
- Order group setup before consumers start in CI.