# NOSCRIPT error

```json metadata
{
  "schema_version": 2,
  "title": "NOSCRIPT error",
  "description": "EVALSHA asked for a script that isn't in the server's script cache.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "tableOfContents": {"sections":[{"id":"example","title":"Example"},{"id":"how-to-fix-it","title":"How to fix it"}]}

,
  "codeExamples": []
}
```


Redis returns this error when you run a Lua script with [`EVALSHA`](https://redis.io/docs/latest/commands/evalsha), but the server doesn't have the script in its script cache. `EVALSHA` runs a script by its SHA1 (Secure Hash Algorithm 1) digest, a short code calculated from the script's source. The server only knows the digest of a script that it has already loaded.

```
NOSCRIPT No matching script. Please use EVAL.
```

In redis-py, this error is `NoScriptError: No matching script. Please use EVAL.`

## Example

```
> EVALSHA ffffffffffffffffffffffffffffffffffffffff 0
(error) NOSCRIPT No matching script. Please use EVAL.
```

## How to fix it

The script cache isn't saved with your data. It's emptied when the server restarts, when a replica becomes the primary, and when someone runs [`SCRIPT FLUSH`](https://redis.io/docs/latest/commands/script-flush). So your code must expect this error at any time:

- **Handle the error in your code.** When you get `NOSCRIPT`, load the script with [`SCRIPT LOAD`](https://redis.io/docs/latest/commands/script-load), or run it once with [`EVAL`](https://redis.io/docs/latest/commands/eval). Then call `EVALSHA` again. Most client libraries can do this for you. For example, the script object that redis-py's `register_script()` returns loads the script again when it gets this error.
- **Use functions instead.** [Functions](https://redis.io/docs/latest/develop/programmability/functions-intro) are saved and replicated with your data, so they're still there after a restart or a failover.

See [Script cache](https://redis.io/docs/latest/develop/programmability/eval-intro#script-cache).

