# node-redis: ClientClosedError: The client is closed

**Code:** `ClientClosedError: The client is closed (node-redis v4)` · **Category:** Redis · **Seen on:** Redis, Node.js

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/redis/node-redis-the-client-is-closed)
