More fixes

"Error establishing a Redis connection"

Every page of your site, the dashboard included, shows "Error establishing a Redis connection". Redis is a fast memory store that some hosts and plugins put in front of the WordPress database so pages load quicker. Your content is not lost: it is still in the database. WordPress was told to ask Redis first, Redis did not answer, and it gave up. Below is a rebuilt example (not a real client), a way to get the site back in two minutes, and the fix for each cause.

What the owner sees

What the check found


  

Get the site back first (two minutes)

  1. Open your files. Use the host's File Manager or an FTP program and go to the wp-content folder.
  2. Rename one file. Find object-cache.php and rename it to object-cache.php.off. This file is what tells WordPress to use Redis. Without it, WordPress reads straight from the database, a little slower but working.
  3. Reload the site. If it comes back, Redis was the whole problem and nothing else is broken. If you now see "Error establishing a database connection" or a critical error, follow that guide instead.
  4. Then find the cause with the table below, fix it, and rename the file back (or turn the cache back on from the plugin, which writes a fresh copy). Leaving it off is safe for a few days, but the site loses the speed Redis was giving it.

Which cause it is

What causes it and the fix

What you seeWhy it happensThe fix
The error appeared after the server rebooted or crashed, and redis-cli ping cannot connectThe Redis service is stopped. It was started by hand once and is not set to start when the server boots, or it crashed when the server ran out of memoryStart it and make it start on boot:
sudo systemctl start redis-server
sudo systemctl enable redis-server
(the service is called redis on some systems). If it keeps dying, check the server's memory: see row 4
The error appeared right after moving to a new host, or on a staging or local copy of the siteobject-cache.php was copied with the rest of wp-content, but the new server has no Redis, or Redis lives at a different addressKeep object-cache.php renamed on that copy. If the new host offers Redis, switch it on in their panel, then turn the cache back on from the plugin so it connects to the new address
Redis is running, but WordPress still cannot reach itThe connection settings in wp-config.php do not match the server: wrong host or port, a password the host changed, a socket path that moved, or a Redis database number in use by another siteCompare these lines with what the host gives you and correct them:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', '...' );
define( 'WP_REDIS_DATABASE', 0 );
A socket setup uses WP_REDIS_SCHEME set to unix and WP_REDIS_PATH instead of host and port. Take a backup of the file first
It fails at busy times, or the plugin's error mentions OOM or maxmemoryRedis is full. With no rule for throwing old entries away, it refuses new writes once it reaches its memory limitGive Redis a limit and let it drop the oldest entries, in redis.conf: maxmemory 256mb and maxmemory-policy allkeys-lru, then restart it. On managed hosting, ask the host to do this or raise the limit
The error started after a hosting plan change or renewal, with no change on your sideThe Redis add-on was removed or moved to a different server with the plan change, but the site still points at itAsk the host whether Redis is still part of the plan. If not, leave object-cache.php renamed and turn the plugin's object cache off. A page cache still keeps a small site fast
It started right after the host changed the PHP versionThe PHP extension that talks to Redis (phpredis) is installed for the old PHP version but not the new oneAsk the host to add the Redis extension for the new PHP version, or in the Redis Object Cache plugin set WP_REDIS_CLIENT to predis, which needs no extension. Check Tools > Site Health > Info to see which version is active

Once it works again, use the plugin's Flush Cache button once, so no half-written entries from the outage are served. For a site that must never show this page, the Redis Object Cache plugin can be told to fall back to the database when Redis does not answer (define( 'WP_REDIS_GRACEFUL', true );); most owners never notice the difference.

What not to do

Renaming one file takes a minute. Finding why Redis died on a VPS that nobody has logged into for a year, moving a site whose host dropped Redis without saying, or tuning memory so it does not happen again at the next sale is where most owners would rather have someone do it. If that is you, the box below is for that. Related: error establishing a database connection, slow site and changes not showing.