NOSCRIPT error

EVALSHA asked for a script that isn't in the server's script cache.

Redis returns this error when you run a Lua script with 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 client libraries

Client libraryException or error typeMessage
redis-py NoScriptError No matching script. Please use EVAL.
Jedis JedisNoScriptException NOSCRIPT No matching script. Please use EVAL.
node-redis SimpleError
Test with err.message.startsWith('NOSCRIPT')
NOSCRIPT No matching script. Please use EVAL.
Lettuce
The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()).
RedisNoScriptException NOSCRIPT No matching script. Please use EVAL.
go-redis redis.Error
Test with errors.Is(err, redis.ErrNoScript)
NOSCRIPT No matching script. Please use EVAL.
ioredis ReplyError
Test with err.message.startsWith('NOSCRIPT')
NOSCRIPT No matching script. Please use EVAL.
StackExchange.Redis
NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions.
RedisServerException NOSCRIPT No matching script. Please use EVAL.
Predis Predis\Response\ServerException
Test with $e->getErrorType() === 'NOSCRIPT'
NOSCRIPT No matching script. Please use EVAL.
redis-rb Redis::NoScriptError NOSCRIPT No matching script. Please use EVAL. (redis://<host>:<port>)
redis-rs
The sync and async APIs raise the same errors.
ErrorKind::Server(ServerErrorKind::NoScript) NoScript: 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. 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, or run it once with 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 are saved and replicated with your data, so they're still there after a restart or a failover.

See Script cache.

RATE THIS PAGE
Back to top ↑