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
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.
You’ll find the Redis cache in the following directory:
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.