# Monitoring Redis with redis-cli

> Use redis-cli to monitor and manage your Redis instance directly from the command line via SSH.

Source: https://www.kualo.com/knowledgebase/perf-caching/monitoring-redis-with-redis-cli
Updated: 2026-06-09

---

**redis-cli** is the Redis command line interface - a simple program that lets you send commands to Redis and read the server's replies directly from the terminal.

## Before you start

You need SSH access to your account to use redis-cli. If you do not have SSH access yet, please [contact us](https://www.kualo.com/company/contact) and we will get that sorted for you.

You also need your Redis socket address. You can find this in cPanel under **Redis**:

![Redis socket address in cPanel](https://kb-cdn.kualo.com/53/7a/537a4afe8cfcc7cd5bccb282d4831e2a1509d6c7.png)

The socket path follows this pattern:

```bash
/home/USER/.kxcache/redis.sock
```

Replace `USER` with your cPanel username throughout the examples below.

## Check that Redis is running

To confirm Redis is responding, run:

```bash
redis-cli -s /home/USER/.kxcache/redis.sock PING
```

You should see:

![PONG response from Redis](https://kb-cdn.kualo.com/e9/a2/e9a207efade7a4e2b9c7d050b1e14fd8eef8736b.png)

A `PONG` reply means Redis is up and accepting connections.

## Monitor commands in real time

To watch every command Redis receives as it happens, run:

```bash
redis-cli -s /home/USER/.kxcache/redis.sock monitor
```

The output looks like this:

```
OK
1460100081.165665 [0 unix:/home/USER/.kxcache/redis.sock] "set" "foo" "bar"
1460100083.053365 [0 unix:/home/USER/.kxcache/redis.sock] "get" "foo"
```

You can pipe the output to filter for specific patterns, for example:

```bash
redis-cli -s /home/USER/.kxcache/redis.sock monitor | grep "set"
```

:::warning
The `monitor` command logs every command received by Redis, which adds overhead. Use it for short debugging sessions rather than leaving it running continuously.
:::

## Check the number of keys in a database

The `dbsize` command returns the number of keys in the currently selected database.

1. Connect to Redis:

   ```bash
   redis-cli -s /home/USER/.kxcache/redis.sock
   ```

2. Select the database you want to check (the default is `0`):

   ```bash
   select 0
   ```

3. Run the command:

   ```bash
   dbsize
   ```

Redis returns the key count as an integer.

## View live server statistics

The `--stat` flag puts redis-cli into continuous stats mode, which is one of its most useful but lesser-known features for monitoring a Redis instance in real time:

```bash
redis-cli -s /home/USER/.kxcache/redis.sock --stat
```

Example output:

```
------- data ------ --------------------- load -------------------- - child -
keys       mem      clients blocked requests             connections
22481      511.69M  3       0       549054 (+0)          71395
22481      511.75M  6       0       549083 (+29)         71401
22481      511.77M  7       0       549103 (+20)         71404
22481      511.79M  8       0       549115 (+12)         71406
22481      511.77M  7       0       549126 (+11)         71408
22481      511.71M  4       0       549132 (+6)          71409
22481      511.71M  4       0       549150 (+18)         71412
22481      511.94M  12      0       549191 (+41)         71421
```

The columns tell you:

- **keys** - how many keys are stored on the server
- **mem** - total memory in use
- **clients** - number of connected clients
- **blocked** - number of blocked clients
- **requests** - total requests served (with the per-interval delta in brackets)
- **connections** - total connections made since startup

This gives you a quick, at-a-glance overview of your Redis server's health and load.

## Flush the Redis cache

To clear all keys from Redis, run:

```bash
redis-cli -s /home/USER/.kxcache/redis.sock flushall
```

:::danger
`flushall` deletes every key in every database immediately and cannot be undone. Only run this if you are sure you want to clear the entire cache.
:::

If you have other useful redis-cli commands you would like to see covered, [let us know](https://www.kualo.com/company/contact) and we will be happy to add them.

---

_Source: Kualo Knowledgebase — https://www.kualo.com/knowledgebase/perf-caching/monitoring-redis-with-redis-cli · © Kualo Ltd._
