Sitelet https://github.com/redis/node-redis/discussions/2884
Skip to content
Discussion options

You must be logged in to vote

Use the top-level name option when creating the client:

import { createClient } from 'redis'

const client = createClient({
  url: process.env.REDIS_URL,
  name: `api:${process.env.HOSTNAME ?? 'local'}`,
})

client.on('error', console.error)
await client.connect()

Node Redis sends that value through HELLO ... SETNAME (RESP3) or CLIENT SETNAME during connection setup, so it appears in the name column of CLIENT LIST.

If the client is already connected, the equivalent command is:

await client.clientSetName('api:worker-1')

A couple of operational details:

  • the name belongs to one physical Redis connection, so subscriber, pool, or separately created clients need their own names;
  • use a stable, …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@XDavidT
Comment options

Answer selected by nkaradzhov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants