# PUBSUB

> Inspect the state of Pub/Sub channels and subscriptions.

URL: https://docs.hotkv.com/commands/pubsub/

```
PUBSUB CHANNELS [pattern]
PUBSUB NUMSUB [channel [channel ...]]
PUBSUB NUMPAT
PUBSUB SHARDCHANNELS [pattern]
PUBSUB SHARDNUMSUB [shardchannel [shardchannel ...]]
PUBSUB HELP
```

- Group: Pub/Sub
- HotKV Cloud: all plans
- On-Premise: no license needed

`PUBSUB` is a container for subcommands that report on Pub/Sub activity on the
node you ask. They only read state and never deliver messages.

| Subcommand | What it returns |
| --- | --- |
| [PUBSUB CHANNELS](https://docs.hotkv.com/commands/pubsub-channels/index.md) | Channels with at least one subscriber |
| [PUBSUB NUMSUB](https://docs.hotkv.com/commands/pubsub-numsub/index.md) | The subscriber count of each named channel |
| [PUBSUB NUMPAT](https://docs.hotkv.com/commands/pubsub-numpat/index.md) | The number of pattern subscriptions |
| [PUBSUB SHARDCHANNELS](https://docs.hotkv.com/commands/pubsub-shardchannels/index.md) | Shard channels with at least one subscriber |
| [PUBSUB SHARDNUMSUB](https://docs.hotkv.com/commands/pubsub-shardnumsub/index.md) | The subscriber count of each named shard channel |
| `PUBSUB HELP` | A short description of each subcommand |

An unknown subcommand replies with
`ERR unknown subcommand '<name>'. Try PUBSUB HELP.`

## Examples

```
127.0.0.1:6379> PUBSUB CHANNELS
1) "news"
127.0.0.1:6379> PUBSUB NUMSUB news
1) "news"
2) (integer) 2
```

## Compatibility

The same subcommands as Redis 7 and Valkey 8. See
[PUBSUB NUMPAT](https://docs.hotkv.com/commands/pubsub-numpat/index.md) for one difference in what it
counts.

## See also

[SUBSCRIBE](https://docs.hotkv.com/commands/subscribe/index.md), [PUBLISH](https://docs.hotkv.com/commands/publish/index.md),
[SSUBSCRIBE](https://docs.hotkv.com/commands/ssubscribe/index.md)