w3resource

Redis Server: CLIENT KILL [ip:port] [ID client-id]

Redis CLIENT KILL Command

Redis CLIENT KILL command is used to close a given client connection.

With the new form, it is possible to kill clients by different attributes instead of killing just by address. Here is the following filters are available:

  • CLIENT KILL ID client-id. Allows to kill a client by its unique ID field.
  • CLIENT KILL TYPE type, where type is one of normal, slave, pubsub. This closes the connections of all the clients in the specified class.
  • CLIENT KILL SKIPME yes/no. By default this option is set to yes, that is, the client calling the command will not get killed, however setting this option to no will have the effect of also killing the client calling the command.

Here are some common uses and scenarios for the "CLIENT KILL" command:

  • Connection Termination: Terminates a specific client connection, useful for managing and controlling access.
  • Resource Management: Helps free up resources by killing long-running or idle connections.
  • Security: Enhances security by allowing the removal of unauthorized or suspicious clients.
  • Load Balancing: Facilitates load balancing by disconnecting clients to manage server load effectively.
  • Maintenance: Useful during maintenance operations to safely disconnect clients without shutting down the server.

Syntax:

Basic syntax of redis CLIENT KILL command is shown below:

CLIENT KILL [ip:port] [ID client-id] [TYPE normal|slave|pubsub] [ADDR ip:port] [SKIPME yes/no] 

Available since

2.4.0.

Return Value

Simple string reply: OK if the connection exists and has been closed

Return Value Type

String

Previous: BGSAVE
Next: CLIENT LIST



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/redis/redis-server-client-kill.php