500 Internal Server Error when enabling Redis on Moodle

Hello, I’m trying to enable Redis on my Moodle installation by adding the following settings to my config.php file:

//$CFG->session_handler_class = '\core\session\redis';
$CFG->session_redis_host = '';
$CFG->session_redis_port = 6379;  // Optional.
$CFG->session_redis_database = 0;  // Optional, default is db 0.
$CFG->session_redis_auth = ''; // Optional, default is don't set one.
$CFG->session_redis_prefix = ''; // Optional, default is don't set one.
$CFG->session_redis_acquire_lock_timeout = 120;
$CFG->session_redis_lock_expire = 7200;
$CFG->session_redis_lock_retry = 100; // Optional wait between lock attempts in ms, default is 100.
//                                    // After 5 seconds it will throttle down to once per second.
//Use the igbinary serializer instead of the php default one. Note that phpredis must be compiled with
//igbinary support to make the setting to work. Also, if you change the serializer you have to flush the database!
$CFG->session_redis_serializer_use_igbinary = false; // Optional, default is PHP builtin serializer.
$CFG->session_redis_compressor = 'zstd'; // Optional, possible values are:
//                                       // 'gzip' - PHP GZip compression
//                                       // 'zstd' - PHP Zstandard compression

However, when I uncomment the first line ($CFG->session_handler_class = '\core\session\redis'; ), I get a 500 Internal Server Error. There are no error messages in my logs. If I leave first line commented, Moodle loads fine but I see 0 hits and 0 everything in redis-stats (lightweight dashboard to show statistics about a Redis server).


PS. Redis is working fine with a WordPress installation on a different subdomain on the same server.

Has anyone encountered a similar issue when trying to use Redis with Moodle? Any help would be greatly appreciated.