“Error establishing a Redis connection” with dockerized WordPress 6.7.1
-
Hello Till,
I’m reaching out regarding an issue we’ve encountered when using the Redis Object Cache plugin with a fresh installation of WordPress 6.7.1. Despite following the official setup guidelines, our WordPress site fails with the following error:
Error establishing a Redis connection
Connection refused
WordPress is unable to establish a connection to Redis. This means that the connection information in your
wp-config.php
file are incorrect, or that the Redis server is not reachable.- Is the correct Redis host and port set?
- Is the Redis server running?
If you need help, please read the?installation instructions.
To disable Redis, delete the
object-cache.php
file in the/wp-content/
directory.Here are the details of our setup:
- WordPress Version: 6.7.1 (fresh installation)
- Redis Plugin Version: Redis Object Cache 2.5.4
- Server Environment:
- Dockerized Setup: Using
docker-compose
- Relevant Containers:
- WordPress (
wordpress:php8.0-fpm
) - Redis (
redis:alpine
) - WP-CLI (
custom-wordpress-cli
built on the official WP-CLI image) - Nginx (
nginx:alpine
) for frontend - MariaDB (
mariadb:latest
) for the database - Varnish (
varnish:stable
) for caching
- WordPress (
- Dockerized Setup: Using
- Redis Configuration:
- Redis is running in the
my-redis
container and is reachable from other containers within the Docker bridge network (my_network
). - Redis configuration: Default Alpine Redis settings (
bind *
,protected-mode no
).
- Redis is running in the
wp-config.php
Constants for Redisdefine("WP_REDIS_HOST", "my-redis");
define("WP_REDIS_PORT", 6379);
define("WP_REDIS_DATABASE", 0);
define("WP_REDIS_DEBUG", true);
define("WP_DEBUG", true);
define("WP_DEBUG_LOG", true);
define("WP_DEBUG_DISPLAY", false);
@ini_set("display_errors", 0);
define("WP_REDIS_TIMEOUT", 5);
define("WP_REDIS_READ_TIMEOUT", 5);
- Plugin Behavior:
- Activating the plugin creates the
object-cache.php
drop-in at/wp-content/
. - The Redis server is accessible (
PONG
response from Redis CLI within the WordPress container). - Enabling Object Cache via the plugin causes the “Error establishing a Redis connection” issue.
- Activating the plugin creates the
Steps we’ve tried:
- Verified network connectivity:
- Pinged
my-redis
from the WordPress container (ping my-redis
works). - Successfully executed
redis-cli -h my-redis ping
from the WordPress container (PONG
response).
- Pinged
- Reviewed Redis logs:
- No errors in Redis logs, and
CONFIG GET
shows the expected settings (bind
,protected-mode
, etc.).
- No errors in Redis logs, and
- Tested Redis connectivity from WP-CLI:
- WP-CLI reports Redis as reachable, but enabling Object Cache causes the same error.
- Tried replacing the
object-cache.php
file:- Replaced it with the latest version from the plugin’s GitHub repository (branch:
develop
).
- Replaced it with the latest version from the plugin’s GitHub repository (branch:
- Reinstalled the plugin:
- Deactivated, uninstalled, and reinstalled the Redis Object Cache plugin. The error persisted.
- Checked for known compatibility issues:
- Verified that Redis Object Cache 2.5.4 supports Redis 7.4.1 and PHP 8.0.
Summary of issue
- Redis is reachable and functional, yet WordPress fails to connect when Object Cache is enabled.
- The error specifically points to
RedisException: Connection refused
in/wp-content/object-cache.php
. - We suspect a compatibility issue between Redis Object Cache and WordPress 6.7.1 but have not found evidence of this in community forums or issue trackers.
Questions:
- Are there known issues with the Redis Object Cache plugin and WordPress 6.7.1 or Redis 7.4.1?
- Could this be related to the
object-cache.php
drop-in, or should we consider alternative configurations for Redis? - Are there any additional debug steps or alternative plugin versions (e.g., pre-releases) we should test?
- You must be logged in to reply to this review.