# NOGROUP error

```json metadata
{
  "schema_version": 2,
  "title": "NOGROUP error",
  "description": "A stream command named a consumer group or stream that doesn't exist.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "tableOfContents": {"sections":[{"id":"example","title":"Example"},{"id":"how-to-fix-it","title":"How to fix it"}]}

,
  "codeExamples": []
}
```


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`](https://redis.io/docs/latest/commands/xreadgroup), [`XPENDING`](https://redis.io/docs/latest/commands/xpending), [`XCLAIM`](https://redis.io/docs/latest/commands/xclaim), and [`XGROUP CREATECONSUMER`](https://redis.io/docs/latest/commands/xgroup-createconsumer) can return it.

```
NOGROUP No such key 'mystream' or consumer group 'mygroup' 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 CREATE`](https://redis.io/docs/latest/commands/xgroup-create) before any consumer reads from it. Add `MKSTREAM` to create the stream as well, if it doesn't exist yet:

    ```
    > XGROUP CREATE mystream mygroup $ MKSTREAM
    OK
    ```

    Without `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`](https://redis.io/docs/latest/commands/xinfo-groups).

If several consumers create the group when they start, see [`BUSYGROUP`](https://redis.io/docs/latest/develop/reference/errors/common/busygroup). For more about consumer groups, see [Consumer groups](https://redis.io/docs/latest/develop/data-types/streams#consumer-groups).

