# How to enable Redis Cache via Unix Socket on Moodle

> Configure Moodle to use Redis for session caching via a Unix socket on your Kualo hosting account.

Source: https://www.kualo.com/knowledgebase/other-apps/how-to-enable-redis-cache-via-unix-socket-on-moodle
Updated: 2026-06-04

---

Connecting Moodle to Redis via a Unix socket gives you faster, more efficient session handling than a TCP connection. This guide walks you through the three steps needed to get it working on your Kualo account.

## Step 1: enable your Redis instance in cPanel

Before touching Moodle, you need to start a Redis instance in cPanel. Follow the instructions in [Enable Redis Unix Socket](/knowledgebase/cpanel-how-tos/how-to-set-up-redis-in-cpanel) to do that.

## Step 2: update config.php

Once your Redis instance is running, add the following lines to your Moodle `config.php` file. Replace `USERNAME` with your cPanel username.

```php
$CFG->session_handler_class = '\core\session\redis';

$CFG->session_redis_host = '/home/USERNAME/.kxcache/redis.sock';
$CFG->session_redis_port = -1;              // Use -1 for a Unix socket; omit for TCP
$CFG->session_redis_database = 0;           // Optional - default is database 0
$CFG->session_redis_prefix = 'sess_';       // Optional - default is no prefix
$CFG->session_redis_acquire_lock_timeout = 120;
$CFG->session_redis_lock_expire = 7200;
$CFG->session_redis_serializer_use_igbinary = true;
```

:::info
The last line enables the IGBinary serialiser, which is faster and more memory-efficient than PHP's default serialiser. To use it, you must enable the `igbinary` extension in the PHP Selector in cPanel. If you prefer not to use IGBinary, simply remove that line and Moodle will fall back to the PHP default serialiser.
:::

## Step 3: configure the Moodle cache store

With the session handler in place, you also need to add Redis as a cache store inside Moodle itself. Follow the official Moodle documentation for the Redis cache store to complete this part of the setup.

If you have any questions, do not hesitate to contact us.

---

_Source: Kualo Knowledgebase — https://www.kualo.com/knowledgebase/other-apps/how-to-enable-redis-cache-via-unix-socket-on-moodle · © Kualo Ltd._
