# NOSCRIPT: Script SHA1 is not cached

> EVALSHA named a script digest the server has not cached since its last restart or SCRIPT FLUSH, so the script must be sent again with EVAL.

Source: https://sqlly.app/errors/redis/noscript
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: `NOSCRIPT`
- Category: Data types and commands

Error message:

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

## What it means

Lua scripts are usually run through EVALSHA <sha1>, which saves sending the whole script on every call. The sha1 is a key into a server-side cache: if the server has never seen the script, or has lost it through a restart, a SCRIPT FLUSH or a failover to a replica that was never sent it, the server refuses with NOSCRIPT instead of guessing. The digest is matched case-insensitively, so one wrong character lands here too.

The standard client pattern is the fallback: try EVALSHA, catch NOSCRIPT, send the full script once with EVAL, then return to EVALSHA. Drivers that support Lua do this transparently; hand-rolled RESP clients have to implement it themselves.

## Common causes

- The server restarted or failed over after the script was loaded, clearing the in-memory script cache.
- SCRIPT FLUSH ran, often from an admin script or a test harness sharing the instance.
- The digest passed to EVALSHA was computed over different text than the script that was loaded.
- A fresh node in a cluster received the EVALSHA before it was ever sent the EVAL.

## How to fix it

1. Send the script once with EVAL, or load it and keep the digest it returns:

   ```sql
   SCRIPT LOAD "return redis.call('GET', KEYS[1])"
   # Returns the sha1 hex string to pass to EVALSHA
   ```
2. Check whether a digest is actually cached before calling it:

   ```sql
   SCRIPT EXISTS <sha1-from-your-logs>
   # 1 means cached; 0 means expect NOSCRIPT
   ```
3. Implement the EVALSHA to NOSCRIPT to EVAL fallback in the client, or use a driver that does it for you.

## Reproduce it safely

```sql
redis-cli EVALSHA 0123456789012345678901234567890123456789 1 mykey
# (error) NOSCRIPT No matching script. Please use EVAL.
redis-cli SCRIPT LOAD "return 1"
# a sha1 hex string comes back
redis-cli EVALSHA <that-sha1> 0
# (integer) 1
```

## How SQLly helps

SQLly prints the NOSCRIPT line verbatim and runs SCRIPT LOAD and EVAL from the editor, so the load-once-then-EVALSHA cycle becomes a copy-paste job in one window rather than a driver change.

## Questions

### Does SCRIPT LOAD survive forever?

No. The cache lives in memory: restarts, SCRIPT FLUSH and failover clear it. Clients must be ready to re-send the script.

### Why does Redis not just return an empty result?

Refusing loudly stops a client from treating a missing script as an empty result, which would look like silent data loss.

## Related errors

- [`BUSY`](https://sqlly.app/errors/redis/busy): Server is blocked by a long script
- [`EXECABORT`](https://sqlly.app/errors/redis/execabort): Transaction discarded after an error
- [`1305`](https://sqlly.app/errors/mysql/1305): MySQL: Function or procedure does not exist

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