Skip to content

Client Commands

Client commands for managing connections, debugging, and controlling client behavior.

CommandSyntaxDescription
CLIENT SETNAMECLIENT SETNAME nameSet connection name
CLIENT GETNAMECLIENT GETNAMEGet connection name
CLIENT LISTCLIENT LISTList all connected clients
CLIENT IDCLIENT IDGet current connection ID
CLIENT INFOCLIENT INFOGet current connection info
CLIENT KILLCLIENT KILL ID idKill a client connection
CLIENT PAUSECLIENT PAUSE msPause all clients
CLIENT UNPAUSECLIENT UNPAUSEResume paused clients

Set a meaningful name for debugging:

Terminal window
127.0.0.1:6379> CLIENT SETNAME worker-1
OK
127.0.0.1:6379> CLIENT GETNAME
"worker-1"
Terminal window
127.0.0.1:6379> CLIENT ID
(integer) 42
Terminal window
127.0.0.1:6379> CLIENT INFO
id=42 addr=127.0.0.1:52341 name=worker-1 db=0 cmd=client
Terminal window
127.0.0.1:6379> CLIENT LIST
id=1 addr=127.0.0.1:52340 name=admin db=0 cmd=client
id=42 addr=127.0.0.1:52341 name=worker-1 db=0 cmd=get
id=43 addr=127.0.0.1:52342 name=worker-2 db=0 cmd=blpop
id=44 addr=127.0.0.1:52343 name= db=1 cmd=set

Each line shows:

  • id - Unique connection ID
  • addr - Client IP and port
  • name - Client name (if set)
  • db - Selected database
  • cmd - Last command executed
Terminal window
# Find the client
127.0.0.1:6379> CLIENT LIST
id=99 addr=192.168.1.100:12345 name=rogue-client db=0 cmd=keys
# Kill by ID
127.0.0.1:6379> CLIENT KILL ID 99
OK

Temporarily pause all client operations (useful for maintenance):

Terminal window
# Pause for 5 seconds
127.0.0.1:6379> CLIENT PAUSE 5000
OK
# All other clients block on commands...
# Or resume early
127.0.0.1:6379> CLIENT UNPAUSE
OK
Terminal window
# List clients to see what they're doing
127.0.0.1:6379> CLIENT LIST
id=1 addr=127.0.0.1:52340 name=web-1 cmd=get
id=2 addr=127.0.0.1:52341 name=web-2 cmd=get
id=3 addr=127.0.0.1:52342 name=batch-job cmd=keys # Slow KEYS command!
Terminal window
# Set descriptive name on connect
CLIENT SETNAME "api-server-pod-abc123"
# Later, in monitoring:
CLIENT LIST
# Can identify which pod/service each connection belongs to
Terminal window
# 1. Pause writes during backup
CLIENT PAUSE 10000
# 2. Perform backup
# ... backup operations ...
# 3. Resume
CLIENT UNPAUSE
Terminal window
# Find clients doing expensive operations
127.0.0.1:6379> CLIENT LIST
id=50 addr=10.0.0.5:43210 name= db=0 cmd=keys # KEYS * is bad!
# Terminate the connection
127.0.0.1:6379> CLIENT KILL ID 50
OK
FieldDescription
idUnique client connection ID
addrClient address (IP:port)
nameClient name from CLIENT SETNAME
dbCurrently selected database (0-15)
cmdLast command executed
Terminal window
# Each app instance names itself
CLIENT SETNAME "app-instance-${HOSTNAME}"
# Ops team can see all connections
CLIENT LIST
Terminal window
# Check how many clients connected
CLIENT LIST
# Count lines to see total connections
# Kill oldest/idle connections if needed
CLIENT KILL ID <oldest_id>
Terminal window
# Which database is this connection using?
CLIENT INFO
# Shows: db=3
# What was the last command?
CLIENT INFO
# Shows: cmd=hgetall
Terminal window
# During deployment:
# 1. Pause old clients
CLIENT PAUSE 30000
# 2. Deploy new version
# 3. Resume (or let timeout expire)
CLIENT UNPAUSE

CLIENT commands are only available in server mode - they manage TCP connections which don’t exist in embedded library mode.

  • All clients (except the one issuing PAUSE) block
  • Read and write commands are paused
  • Pub/Sub messages are still delivered
  • Timeout in milliseconds
  • Names have no spaces or special characters
  • Empty string clears the name
  • Names are for debugging only, no security implications
  • CLIENT KILL immediately closes the TCP connection
  • Client will need to reconnect
  • Use for misbehaving clients or maintenance