# BUSY: Server is blocked by a long script

> A Lua script is still running and Redis is single-threaded: until it ends or is killed, only SCRIPT KILL and SHUTDOWN NOSAVE are accepted.

Source: https://sqlly.app/errors/redis/busy
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Error prefix: `BUSY`
- Category: Data types and commands

Error message:

```text
BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.
```

## What it means

Redis executes commands in one thread. A Lua script that runs too long, an accidental infinite loop being the classic case, blocks that thread, and every other client gets BUSY for its commands. The two escape hatches are named in the message: SCRIPT KILL from another connection stops the script if it has not written anything, and SHUTDOWN NOSAVE stops the server when it has, because a script that is mid-write cannot be undone safely.

The reply tells you the state you are in: if the script already performed writes, SCRIPT KILL refuses and the only way out is SHUTDOWN NOSAVE, losing unsaved data since the last save. That is why unbounded loops in scripts deserve the same review as unbounded loops anywhere else.

## Common causes

- A Lua script with an unbounded loop, or a scan that never reaches its end condition.
- A script calling an expensive redis.call repeatedly against a large keyspace.
- A Redis Function (7+) stuck the same way; the matching kill command is FUNCTION KILL.

## How to fix it

1. From a second connection, kill the script if it has not written:

   ```sql
   SCRIPT KILL
   # OK - the blocked clients resume
   ```
2. If SCRIPT KILL refuses because the script already wrote, and the dataset is disposable, the last resort is:

   ```sql
   SHUTDOWN NOSAVE
   ```
3. Fix the script afterwards: bound every loop, limit ranges, and test long scripts on a scratch instance first.

## Reproduce it safely

Run this only against a scratch instance: until SCRIPT KILL lands, that server answers nothing else.

```sql
redis-server --port 7304 --save '' &
redis-cli -p 7304 EVAL "while true do end" 0 &
redis-cli -p 7304 PING
# (error) BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.
redis-cli -p 7304 SCRIPT KILL
# OK
```

## How SQLly helps

If a script loops, other Redis tabs in SQLly get the BUSY line verbatim instead of a timeout, and a second connection's SCRIPT KILL runs from the same editor, so recovery does not need a shell.

## Questions

### SCRIPT KILL says the script already wrote. Now what?

The script cannot be stopped mid-write. The options in the message are the whole truth: wait for it to finish, or SHUTDOWN NOSAVE and lose data since the last save.

### Does BUSY mean the server crashed?

No. Redis is alive and single-threaded, waiting on your script. That is exactly why every other client sees BUSY.

## Related errors

- [`NOSCRIPT`](https://sqlly.app/errors/redis/noscript): Script SHA1 is not cached
- [`SQLITE_BUSY`](https://sqlly.app/errors/sqlite/sqlite-busy): SQLite: database is locked
- [`57014`](https://sqlly.app/errors/postgresql/57014): PostgreSQL: canceling statement

The code and message text are from the [Redis documentation and source code](https://redis.io/docs/latest/).
