Skip to main content
Use PUNSUBSCRIBE to cancel pattern subscriptions of the current connection. With no arguments the connection unsubscribes from every pattern it registered, otherwise only from the patterns named, which must be given exactly as they were passed to PSUBSCRIBE, since patterns are matched literally here and not expanded. The server sends one confirmation per pattern with the number of subscriptions still active. Exact-channel subscriptions are not affected; cancel those with UNSUBSCRIBE.

Syntax

Arguments

Important points

  • This is a connection-oriented command and is available over native Redis TCP, not the stateless REST endpoint.
  • Subscription commands require a dedicated TCP connection. In RESP3, subscription events use push replies.

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.