ClientClosedError: The client is closed (node-redis v4) Redis Origin: Data Last updated 5 Nov 2026

node-redis: ClientClosedError: The client is closed

A command was sent through a node-redis client that was never connected, was quit(), or disconnected.

Exact message you may see ClientClosedError: The client is closedThe client is closed node-redisError: The client is closedClientClosedError node-redis v4Error: Socket closed unexpectedly
Seen on: Redis Node.js

Meaning

In node-redis v4 you must await client.connect() before commands and handle client.on('error'). Don't call commands after quit()/disconnect(). Create one client at startup, reuse it, and in serverless re-use across invocations.

Common causes

  • connect() not called/awaited
  • Commands after client.quit()
  • Client created per request and closed
  • Connection error closing it without reconnect strategy
  • Missing error listener causing crash

⚡ Quick fix

  1. const client = createClient({ url }); client.on("error", console.error); await client.connect();
  2. Reuse a singleton client
  3. Don't quit before pending commands finish

Detailed fix by platform

Node.js

  1. import { createClient } from "redis"; const client = createClient({ url: process.env.REDIS_URL }); client.on("error", e => console.error(e)); await client.connect();

How to diagnose

  1. connect — Awaited?
  2. Lifecycle — Closed early?
  3. Listener — error handler?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

BullMQ: Missing lock for job / job stalled more than allowable limit — BullMQ: Error: Missing lock for job 42. moveToFinished / job stalled more than allowable limit (Redis)BullMQ: Missing lock …BUSY Redis is busy running a script — Redis: (error) BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE (Redis)BUSY Redis is busy ru…Celery with Redis: tasks run twice (visibility_timeout) — Celery: Task executed twice / Restoring unacked messages — Redis broker visibility_timeout shorter than task ETA (Redis)Celery with Redis: ta…Client output buffer limit reached (scheduled to be closed) — Redis: Client id=12 addr=10.0.0.5:51234 scheduled to be closed ASAP for overcoming of output buffer limits (Redis)Client output buffer …ECONNRESET / Connection reset by peer on idle Redis connection — Redis: Error: read ECONNRESET / redis.exceptions.ConnectionError: Connection reset by peer after idle time (Redis)ECONNRESET / Connecti…Error: connect ECONNREFUSED 127.0.0.1:6379 — Redis: Error: connect ECONNREFUSED 127.0.0.1:6379 / Could not connect to Redis at 127.0.0.1:6379: Connection refused (Redis)Error: connect ECONNR…MaxRetriesPerRequestError: Reached the max retries per request limit — ioredis: MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details (Redis)MaxRetriesPerRequestE…Only (P|S)SUBSCRIBE / (P|S)UNSUBSCRIBE / PING / QUIT allowed in this context — Redis: ERR Can't execute 'get': only (P|S)SUBSCRIBE / (P|S)UNSUBSCRIBE / PING / QUIT / RESET are allowed in this context (Redis)Only (P|S)SUBSCRIBE /…ClientClo…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.