Difficulty: Beginner
How do you find the unique ID of the current Redis connection, and what is that ID actually used for?
Run CLIENT ID. It returns a 64-bit integer that uniquely identifies the current connection on that server; IDs increase monotonically and are never reused while the server runs. You use it to target that connection from elsewhere, for example CLIENT KILL ID <id>, CLIENT UNBLOCK <id> or CLIENT TRACKING ON REDIRECT <id>.
CLIENT ID is O(1). It has existed since Redis 5.0. HELLO (Redis 6+) also returns the ID in its reply.| Command | Purpose |
|---|---|
CLIENT INFO | Details of the current connection (6.2+) |
CLIENT LIST | One line per connected client with id=, addr=, name=, idle=, cmd= |
CLIENT LIST ID 7 9 | Filter the list by IDs |
CLIENT SETNAME / CLIENT GETNAME | Attach a readable name like order-service |
CLIENT KILL ID <id> | Close one specific connection |
CLIENT UNBLOCK <id> | Wake a client stuck in BLPOP, XREAD BLOCK, etc. |
CLIENT TRACKING ON REDIRECT <id> | Send client-side cache invalidations to another connection |
CLIENT SETINFO LIB-NAME ... | Libraries report their name and version (7.2+) |
CLIENT LIST with name= and addr= tells you which service is not closing connections, and the IDs tell you how fast new ones appear.KEYS * can be stopped with CLIENT KILL ID 18231 without touching anything else on that host. Killing by ADDR works too, but ports can be reused; IDs cannot.BRPOP for 30 seconds can be released immediately with CLIENT UNBLOCK id so deploys finish faster.__redis__:invalidate, and you pass that connection's ID in REDIRECT.CLIENT ID through a pooled client may hit a different connection than the next command. Use a dedicated connection when the ID matters.CLIENT SETNAME your services. IDs are opaque numbers; names make CLIENT LIST readable during an incident.CLIENT KILL and CLIENT LIST are in the @dangerous / @admin ACL categories, so application users usually should not have them.# In connection A
CLIENT SETNAME payment-worker
CLIENT ID
# -> (integer) 412
BLPOP jobs:payments 0 # blocks forever
# In connection B (an admin shell)
CLIENT LIST ID 412
CLIENT UNBLOCK 412 # A returns nil and continues
CLIENT KILL ID 412 # or close the connection entirely
The ID lets an admin connection target exactly one client, even if many share the same host.
CLIENT ID, CLIENT LIST, CLIENT KILL, CLIENT SETNAME, Connection tracking