# DEBUG

> Diagnostic and testing subcommands, disabled unless enable-debug-command allows them.

URL: https://docs.hotkv.com/commands/debug/

```
DEBUG subcommand [argument ...]
```

- Group: Server
- HotKV Cloud: all plans
- On-Premise: no license needed

`DEBUG` groups subcommands for diagnosing a server. Some
of them can stop the server or replace its data, so `DEBUG` is refused
unless the `enable-debug-command` setting allows it:

| `enable-debug-command` | Who can run `DEBUG` |
| --- | --- |
| `no` (default) | Nobody. |
| `local` | Clients connected over a loopback address (`127.0.0.1`, `::1`). |
| `yes` | Any client whose ACL user may run it. |

The setting can only be changed in the config file, followed by a restart.
Otherwise every `DEBUG` call fails with:

```
ERR DEBUG command not allowed. If the enable-debug-command option is set to "local", you can run it from a local connection, otherwise you need to set this option in the configuration file, and then restart the server.
```

`DEBUG` cannot be run from a script. `DEBUG HELP` lists the subcommands.

## Subcommands

| Subcommand | What it does | Reply |
| --- | --- | --- |
| `SLEEP seconds` | Stop the whole server for `seconds` (fractions allowed): no command runs meanwhile, and in a cluster the node stops talking to other nodes too. Useful to test client timeouts and failover. | `OK` |
| `OBJECT key` | One line about a key. Its `encoding` (as [OBJECT ENCODING](https://docs.hotkv.com/commands/object-encoding/index.md) gives it) and `lru_seconds_idle` (seconds since last access) are meaningful; the other fields are fixed placeholders. `ERR no such key` if it does not exist. | Simple string |
| `POPULATE count [prefix] [size]` | Create string keys `prefix:0` to `prefix:<count-1>` (prefix `key` by default) holding `value:<n>`, padded with zero bytes or cut to `size` bytes when `size` is given. Existing keys are left as they are. For diagnostics only: these keys are not written to the AOF or sent to replicas. | `OK` |
| `DIGEST` | A 40-hex-digit digest of every database's keys, types, values and expiry. Two servers with the same data give the same digest, which makes it easy to check a replica or a restore. All zeros when there are no keys. | Simple string |
| `DIGEST-VALUE key [key ...]` | The digest of each key's value, all zeros for a missing key. | Array of simple strings |
| `LOG message` | Write `message` to the server log, for marking a point in the log during tests. | `OK` |
| `RELOAD [NOSAVE]` | Write a snapshot (unless `NOSAVE`). The data in memory is not reloaded from it. | `OK` |
| `LOADAOF` | Write the AOF to disk, empty the data set, and load it again from the AOF. Needs `appendonly yes`. | `OK` |
| `RESTART [milliseconds]` | Shut down as [SHUTDOWN](https://docs.hotkv.com/commands/shutdown/index.md) does, rewrite the config file as [CONFIG REWRITE](https://docs.hotkv.com/commands/config-rewrite/index.md) does, and start the server again after the delay with the same arguments. No reply. | None |
| `SET-ACTIVE-EXPIRE 0\|1` | Turn the background removal of expired keys off (`0`) or on. With it off, expired keys are removed only when a command finds them. | `OK` |
| `CHANGE-REPL-ID` | Accepted, with no effect. | `OK` |
| `PAUSE-CRON 0\|1` | Accepted, with no effect. | `OK` |
| `CLIENT-EXTRA-MEMORY bytes` | Count that many more bytes in this connection's `tot-mem` and toward `maxmemory-clients`, from the end of the command. Useful to check how client eviction behaves. | `OK` |

`DEBUG HELP` lists further diagnostic subcommands, including some for
clusters.

Errors: `ERR unknown DEBUG subcommand '<NAME>'. Try DEBUG HELP.` for an
unknown subcommand, and the usual argument errors.

## Examples

```
127.0.0.1:6379> DEBUG DIGEST
0000000000000000000000000000000000000000
127.0.0.1:6379> DEBUG POPULATE 3
OK
127.0.0.1:6379> DEBUG DIGEST-VALUE nosuchkey
1) 0000000000000000000000000000000000000000
127.0.0.1:6379> DEBUG SLEEP 0.5
OK
```

In HotKV Cloud, the CLI tab of the panel does not run `DEBUG`.

## Compatibility

Redis 7 and Valkey 8 gate `DEBUG` with the same setting and messages, and
have many more subcommands. HotKV has the subcommands that operators
rely on. Differences in the ones it has:
`RELOAD` saves but does not reload, `OBJECT` reports placeholder values for
fields other than the encoding and idle time, and `CHANGE-REPL-ID` does
nothing.

## See also

[OBJECT ENCODING](https://docs.hotkv.com/commands/object-encoding/index.md), [MEMORY USAGE](https://docs.hotkv.com/commands/memory-usage/index.md),
[SHUTDOWN](https://docs.hotkv.com/commands/shutdown/index.md), [configuration reference](https://docs.hotkv.com/reference/configuration/index.md)