Fixing Moodle: Failed to unserialise data from file. Either failed to read, or failed to write.

Updated

From time to time (and typically when a server experiences difficulties and has to be rebooted), Moodle will return such an error when trying to access the site. This can occur on all pages served by Moodle, or only on particular pages.

Usually it's the result of a broken file stored in the Moodle cache. In such an event, a simple purge of all Moodle caches will resolve the issue.

For some times, the challenge is that Moodle is completely inaccessible via the browser. In this instance, cd into the Moodle root directory via SSH, and run the following command:

sudo -u apache php admin/cli/purge_caches.php

If this doesn't work alone, you should also attempt to remove all files and folders within the /moodledata/cache directory.

These two administrative processes in combination will in most cases resolve the issue, by purging the Moodle cache data, and eliminating any problematic or corrupt files or data that exists there.