How to Fix the 'Error establishing a Redis connection' in WordPress

intermediate📝 WordPress2026-07-05| Ubuntu/CentOS, Nginx/Apache, WordPress 5.0+, Redis Server, PHP-Redis extension

Error Message

Error establishing a Redis connection
#redis#object-cache#wordpress-optimization#server-management#php

The ProblemYou open your WordPress dashboard and see a frustrating warning: Error establishing a Redis connection. This happens when your WordPress plugin—typically Redis Object Cache or WP Redis—loses its handshake with the Redis server. While your site might still load using a fallback, your performance will tank. Page load times often jump from a snappy 200ms to over 2 seconds because the database has to do all the heavy lifting without a cache.

Common Causes- The Redis service crashed or didn't start after a reboot.- The PHP-Redis extension is missing, especially after a PHP version upgrade.- Wrong credentials or host settings in wp-config.php.- Redis is listening on the wrong IP or port.- The server ran out of RAM, and the Linux OOM (Out Of Memory) killer terminated the Redis process.## Step 1: Check if Redis is Actually RunningMost of the time, the service has simply stopped. Log into your server via SSH and check the status immediately.

# For Ubuntu/Debian
sudo systemctl status redis-server

# For CentOS/RHEL
sudo systemctl status redis

If the output shows inactive (dead) or failed, try to kickstart the service:

sudo systemctl start redis-server

To prevent this from happening after your next server maintenance, ensure it starts on boot:

sudo systemctl enable redis-server

Step 2: Test the Connection ManuallyA running service doesn't always mean a working connection. Use the built-in redis-cli tool to ping the server and check its responsiveness.

redis-cli ping

A healthy server will reply with PONG. If you see "Connection refused," Redis might be configured to use a Unix socket instead of a TCP port, or it's listening on a different port entirely.

Step 3: Verify the PHP-Redis ExtensionWordPress can't talk to Redis without a translator. That translator is the PHP-Redis extension. If you recently bumped your site from PHP 8.1 to 8.3, the extension might be missing for the new version.

Run this command to see if the module is active:

php -m | grep redis

If the result is blank, install the extension. For a server running PHP 8.3 on Ubuntu, use:

sudo apt install php8.3-redis
sudo systemctl restart php8.3-fpm
sudo systemctl restart nginx

Step 4: Audit Your wp-config.php SettingsIf the server is healthy but WordPress is still complaining, your configuration is likely the culprit. Open your wp-config.php file and verify these constants.

define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
// define('WP_REDIS_PASSWORD', 'your-secret-password');

Watch out for these common traps:

  • Localhost vs 127.0.0.1: Some servers fail to resolve localhost correctly. Use 127.0.0.1 to be safe.- Password Protection: If you set a requirepass in your redis.conf, you must include it in your config.- Unix Sockets: If you want better performance, use a socket path like /var/run/redis/redis.sock instead of an IP address.## Step 5: Check Firewall and Bind AddressAre you running Redis on a separate database server? If so, Redis defaults to only allowing local connections. You need to edit /etc/redis/redis.conf to allow outside traffic.
# Find this line:
bind 127.0.0.1

# Change it to include your web server's private IP:
bind 127.0.0.1 10.0.0.5

After updating the config, restart Redis. Don't forget to open port 6379 on your firewall (UFW or Firewalld) to allow the web server through.

How to Verify the Fix- The Dashboard Test: Navigate to Settings > Redis in WordPress. You want to see a bright green "Connected" status.- Live Monitoring: Run redis-cli monitor in your terminal and refresh your website. If you see a flood of GET and SET commands, the connection is live.- Check the Logs: If things still feel broken, check /var/log/redis/redis-server.log for specific memory or permission errors.## Pro Tips for Stability- Memory Management: Redis lives in your RAM. If your server only has 2GB of RAM, set a maxmemory 512mb limit in redis.conf so it doesn't crash your entire OS.- Eviction Policy: Set maxmemory-policy allkeys-lru. This tells Redis to delete the oldest, least-used cache files when it runs out of space, rather than just stopping.

Related Error Notes