Skip to content
Latchkey

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".

Terminal
NOGROUP No such key 'events' or consumer group 'workers' in XREADGROUP with GROUP option

Common 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.

Terminal
redis-cli XGROUP CREATE events workers $ MKSTREAM

Create the group idempotently at startup

Attempt the create and ignore the BUSYGROUP error if it already exists, before any XREADGROUP.

  1. Run XGROUP CREATE ... MKSTREAM during app startup.
  2. Catch and ignore "BUSYGROUP Consumer Group name already exists".
  3. 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →