{
  "schema_version": 2,
  "id": "commands/client-setname",
  "title": "CLIENT SETNAME",
  "url": "https://redis.io/docs/latest/commands/client-setname/",
  "summary": "Sets the connection name.",
  "since": "2.6.9",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:21+01:00",
  "page_type": "content",
  "content_hash": "5fa04ca3afb85165f59be276c7be7453cffe7f61b671fa60062485d3574c5502",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "The `CLIENT SETNAME` command assigns a name to the current connection."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>connection-name</code></summary>\n\nThe name to assign to the current connection.\n\n</details>"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": "The assigned name is displayed in the output of [`CLIENT LIST`](https://redis.io/docs/latest/commands/client-list) so that it is possible to identify the client that performed a given connection.\n\nFor instance when Redis is used in order to implement a queue, producers and consumers of messages may want to set the name of the connection according to their role.\n\nThere is no limit to the length of the name that can be assigned if not the usual limits of the Redis string type (512 MB). However it is not possible to use spaces in the connection name as this would violate the format of the [`CLIENT LIST`](https://redis.io/docs/latest/commands/client-list) reply.\n\nIt is possible to entirely remove the connection name setting it to the empty string, that is not a valid connection name since it serves to this specific purpose.\n\nThe connection name can be inspected using [`CLIENT GETNAME`](https://redis.io/docs/latest/commands/client-getname).\n\nEvery new connection starts without an assigned name.\n\n> [!TIP]\n> Setting names to connections is a good way to debug connection leaks due to bugs in the application using Redis."
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK` if the connection name was successfully set.\n\n**RESP3:**\n\n[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK` if the connection name was successfully set."
    }
  ],
  "examples": []
}
