# CLIENT SETNAME

> Give the current connection a name that shows in CLIENT LIST and the slow log.

URL: https://docs.hotkv.com/commands/client-setname/

```
CLIENT SETNAME connection-name
```

- Group: Connection
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`CLIENT SETNAME` names the current connection. The name appears as `name=` in
[CLIENT LIST](https://docs.hotkv.com/commands/client-list/index.md) and [CLIENT INFO](https://docs.hotkv.com/commands/client-info/index.md),
and in [SLOWLOG GET](https://docs.hotkv.com/commands/slowlog-get/index.md) entries, which makes it much
easier to tell which application or worker a connection belongs to. An empty
string removes the name.

The name cannot contain spaces, newlines or other non-printable characters,
so that `CLIENT LIST` stays easy to parse. [HELLO](https://docs.hotkv.com/commands/hello/index.md) can set
the name too, with its `SETNAME` option.

## Return value

| Case | Reply (RESP2 and RESP3) |
| --- | --- |
| Name set | Simple string `OK` |
| Name with a space or special character | Error `ERR Client names cannot contain spaces, newlines or special characters.` |

## Examples

```
127.0.0.1:6379> CLIENT SETNAME billing-worker-3
OK
127.0.0.1:6379> CLIENT GETNAME
"billing-worker-3"
127.0.0.1:6379> CLIENT SETNAME "billing worker"
(error) ERR Client names cannot contain spaces, newlines or special characters.
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[CLIENT GETNAME](https://docs.hotkv.com/commands/client-getname/index.md), [CLIENT SETINFO](https://docs.hotkv.com/commands/client-setinfo/index.md),
[CLIENT LIST](https://docs.hotkv.com/commands/client-list/index.md), [HELLO](https://docs.hotkv.com/commands/hello/index.md)