Software & Applications

How to setup Redis Object Cache plugin wordpres with requirepass

To use the Redis Object Cache plugin in WordPress with a password-protected Redis server, follow these steps. The process involves installing and configuring the Redis server, installing the plugin, and updating your WordPress configuration to include the password

Prerequisites

  • Redis server is running and has requirepass set in its configuration (redis.conf or via CLI).

  • WordPress site has the Redis Object Cache plugin installed.

  • Redis PHP extension is installed and enabled (phpredis recommended).

1. Set the Redis password in wp-config.php

Edit your wp-config.php file and add the following constants before the line

define('WP_REDIS_HOST', '127.0.0.1');         // or the IP/hostname of your Redis server
define('WP_REDIS_PORT', 6379);                // default Redis port
define('WP_REDIS_PASSWORD', 'your_redis_password_here');

If your Redis uses a socket instead of a host/port, you can also use:

define('WP_REDIS_PATH', '/var/run/redis/redis.sock');

2. Activate the Plugin

Go to your WordPress admin → Plugins → Activate Redis Object Cache.

Then go to Settings → Redis, and click Enable Object Cache.

If the connection is successful, you’ll see a green checkmark and stats like uptime, memory usage, etc.

Test Redis Connection

From your terminal or PHP shell:

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->auth('your_redis_password_here');
echo $redis->ping(); // Should output: PONG

Troubleshooting

ProblemSolution
❌ Redis connection failedCheck that redis-server is running and accessible from your WordPress host
❌ Authentication errorMake sure the password in wp-config.php matches the one in redis.conf
❌ Plugin not cachingEnsure object cache is enabled in Settings → Redis, and check wp-content/object-cache.php exists