Skip to content

Fix: Error establishing a Redis connection

  • by
  • 3 min read

A proper web data structure and caching solution is necessary to deliver a good user experience on your web app, whether a tool or an e-commerce site. However, this also means that if there’s something wrong with your caching system, it can cause problems for the whole site. 

In this article, we’re talking about the “Fix: Error establishing a Redis connection” error in Redis, its causes, and how to fix the problem. 


What causes the error in establishing a Redis connection?

The error is generally caused by either the server not running or the wp-config.php file for Wordpress either missing the Redis configuration or having an incorrect one. On other platforms, this error can be caused by the following reasons:

  • The Redis server is down
  • The Redis server isn’t configured properly
  • The web application can’t access the Redis server
  • Web app configuration issues

Also read: Fix: WP error: Could not insert the attachment into the database


How to fix any errors establishing a Redis connection?

Here are four fixes you can try out. 

Restart your Wordpress site

If you’re having Redis issues with Wordpress, restarting your site should be the first thing on your troubleshooting list. Restarting the site will also flush the plugin and, by extension, Redis cache, forcing it to reload and access the configuration file again. 


Check Redis configuration

Next up, check to see if Redis is configured properly in the wp-config.php file of your Wordpress installation. Next, locate the Redis configuration settings inside the file and ensure the host, port and password values are set correctly. 

This is how a proper Redis configuration should look in your Wordpress configuration settings. 

define( 'WP_REDIS_HOST', '123.456.789.000' );
define( 'WP_REDIS_PORT', [enter port number]);
define( 'WP_REDIS_PASSWORD', 'enter password );
define( 'WP_REDIS_CLIENT', 'predis' );
define( 'WP_REDIS_PREFIX', 'my-site' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );

Delete the Redis cache file

If the configuration is correct and Redis refuses to connect, the next step is to delete the Redis cache file and let the server generate it again to fix any corruptions that might be keeping Redis from functioning properly. 

How to change theme in Wordpress? Candid.Technology

You’ll find the Redis cache in the following directory:

wp-content/plugins/redis-cache/

Contact the plugin developer

If nothing else works, your best bet is to contact Redis Support. They offer a community forum that can help you get free support from the community. Contact their dedicated customer support portal for more help if you have a Redis Commercial license.

Also read: Animated GIF not working in WordPress: Quick Fix

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>