# SCRIPT KILL

> Stop the script that is currently running, if it has not written yet.

URL: https://docs.hotkv.com/commands/script-kill/

```
SCRIPT KILL
```

- Group: Scripting and functions
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`SCRIPT KILL` stops the Lua script or function that is running on another
connection, for example one stuck in a loop. The script's caller gets the
error `ERR Script killed by user with SCRIPT KILL...`. Once the running script
has run longer than `busy-reply-threshold`, other clients get `BUSY` errors,
and `SCRIPT KILL` is one of the few commands they can still send.

A script that has already written cannot be stopped this way, since stopping
it halfway would break atomicity. Wait for it to finish, or stop the server
with `SHUTDOWN NOSAVE`.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| The script was stopped | Simple string `OK` | Simple string `OK` |
| No script is running | Error `NOTBUSY No scripts in execution right now.` | Error |
| The script has written | Error `UNKILLABLE Sorry the script already executed write commands against the dataset. ...` | Error |

## Examples

```
127.0.0.1:6379> SCRIPT KILL
(error) NOTBUSY No scripts in execution right now.
```

## Compatibility

Same replies as Redis 7 and Valkey 8, with one difference: `SCRIPT KILL` and
[FUNCTION KILL](https://docs.hotkv.com/commands/function-kill/index.md) each stop either a script or a
function, where Redis lets `SCRIPT KILL` stop only scripts run with `EVAL` and
`FUNCTION KILL` only functions.

## See also

[FUNCTION KILL](https://docs.hotkv.com/commands/function-kill/index.md), [EVAL](https://docs.hotkv.com/commands/eval/index.md),
[SHUTDOWN](https://docs.hotkv.com/commands/shutdown/index.md)