Use CLIENT SETNAME to label the current connection with a name of your choice.
The name shows up in CLIENT LIST and CLIENT INFO output, which is handy when several components of an application share one database and you want to tell their connections apart. The name may not contain spaces or newlines, each call replaces the previous name, and passing an empty string clears it. It lives only as long as the connection.
Syntax#
Arguments#
| Argument | Required | Repeatable | Description |
|---|---|---|---|
connection-name | Yes | No | Name to associate with this TCP connection. |
Important points#
- This is a connection-oriented command and is available over native Redis TCP, not the stateless REST endpoint.
- This command can expose administrative information or make a broad destructive change. Restrict it to trusted code paths.
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.
| Protocol | Reply |
|---|---|
| RESP2 | Simple string OK |
| RESP3 | Simple string OK |
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.