# CLIENT KILL

> Close client connections by address, or every connection that matches a set of filters.

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

```
CLIENT KILL ip:port
CLIENT KILL [ID client-id] [TYPE NORMAL | MASTER | REPLICA | PUBSUB] [USER username] [ADDR ip:port] [LADDR ip:port] [SKIPME YES | NO] [MAXAGE seconds]
```

- Group: Connection
- Complexity: O(N) where N is the number of client connections
- HotKV Cloud: all plans
- On-Premise: no license needed

`CLIENT KILL` closes client connections. It has two forms:

- **Address form**: `CLIENT KILL ip:port` closes the one connection whose
  client address (the `addr` field of [CLIENT LIST](https://docs.hotkv.com/commands/client-list/index.md))
  matches.
- **Filter form**: one or more `option value` pairs. Every connection that
  matches all the filters is closed.

A connection being closed gets no further replies. If it is in the middle of
a command, that command finishes first.

## Options

| Filter | Matches |
| --- | --- |
| `ID client-id` | The connection with this id. The id must be greater than 0. |
| `TYPE type` | Connections of this type: `normal` or `pubsub` (`slave` is taken as `replica`). `master` and `replica` never match a connection. |
| `USER username` | Connections logged in as this ACL user. The user must exist. |
| `ADDR ip:port` | The connection from this client address. |
| `LADDR ip:port` | Connections to this local address, as the `laddr` field shows it. |
| `SKIPME YES \| NO` | Whether the connection running the command is left open. Default `YES`. |
| `MAXAGE seconds` | Connections open for at least this many seconds. |

## Return value

| Case | Reply (RESP2 and RESP3) |
| --- | --- |
| Address form, connection found | Simple string `OK` |
| Address form, no such connection | Error `ERR No such client` |
| Filter form | Integer: the number of connections closed |

Filter form errors: `ERR client-id should be greater than 0`,
`ERR Unknown client type '<type>'`, `ERR No such user '<username>'`,
`ERR maxage is not an integer or out of range`, and `ERR syntax error` for an
unknown filter, a missing value, or a `SKIPME` value other than `YES` or `NO`.

## Examples

```
127.0.0.1:6379> CLIENT KILL 10.0.0.21:40118
OK
127.0.0.1:6379> CLIENT KILL USER batch-job
(integer) 3
127.0.0.1:6379> CLIENT KILL TYPE pubsub MAXAGE 3600
(integer) 1
127.0.0.1:6379> CLIENT KILL ID 99999
(integer) 0
```

## Compatibility

Same forms, filters and replies as Redis 7.4 and Valkey 8, except that the
`master` and `replica` types never match a connection.

## See also

[CLIENT LIST](https://docs.hotkv.com/commands/client-list/index.md), [CLIENT ID](https://docs.hotkv.com/commands/client-id/index.md),
[CLIENT PAUSE](https://docs.hotkv.com/commands/client-pause/index.md), [ACL DELUSER](https://docs.hotkv.com/commands/acl-deluser/index.md)