Skip to content

Error establishing a Redis connection in WordPress: fixes

Fix the WordPress "Error establishing a Redis connection" screen by getting the site back up first, then reading the technical message behind it. Each message, from "Connection refused" to a Redis server that has run out of memory, is matched to its cause and its fix.

Your WordPress site shows a plain page that says “Error establishing a Redis connection”, and you are the owner or administrator who has to bring it back. The screen comes from the Redis Object Cache plugin, which keeps the results of repeated database lookups in Redis, a data store that lives in memory. When Redis fails to answer, the plugin stops the page. One line in wp-config.php turns the cache off and brings the site back. After that, a short technical message tells you which of a few causes you have, and each cause has a known fix.

What you’ll accomplish

  • Bring the site back online with a one-line change, without deleting anything.
  • Read the real error behind the screen, such as Connection refused or NOAUTH.
  • Match that message to its cause and apply the fix.
  • Turn the cache back on and confirm that the plugin reports Connected.

Prerequisites

  • The Redis Object Cache plugin by Till Krüss. The messages and constants quoted here were checked against version 3.0.1. Object Cache Pro, LiteSpeed Cache and W3 Total Cache show their own messages.
  • A way to edit wp-config.php: SSH, SFTP or your control panel’s file manager.
  • For the checks on Redis itself, shell access to the server and the redis-cli tool. WP-CLI (the wp command) is used at the end.
  • Redis 6 or newer for the parts about ACL users, which are named Redis accounts with their own password and permissions.

How it works

Path of a WordPress page request to Redis in three stages, each with the error messages it can produce. Connect, over a TCP port or a unix socket, can fail with "Connection refused", "No such file or directory" or "Permission denied". Sign in, with a password or an ACL user, can fail with NOAUTH or WRONGPASS. Run commands, the reads and writes, can fail with LOADING, OOM or MISCONF. Every one of these messages ends on the same highlighted screen, "Error establishing a Redis connection". When all three stages pass, the page is served.

The plugin works through one file, wp-content/object-cache.php. WordPress calls this kind of file a drop-in: it loads the file on every request, before any plugin, and uses it in place of its built-in cache.

On each request, the drop-in does three things. It connects to Redis over a TCP port or a unix socket, which is a special file that two programs on the same server use to talk. It signs in, if a password is set. Then it reads and writes cached values while the page is built.

A failure at any of the three stages produces the same screen. The heading is always “Error establishing a Redis connection”, even when the connection itself is fine and Redis refused a write because its memory is full. The message underneath is what you need, and the plugin shows it in only two cases: on a /wp-admin/ address, or when WP_DEBUG is on. Visitors see the heading and one line about deleting object-cache.php.

The plugin’s WP_REDIS_GRACEFUL constant, false by default, keeps the site loading when Redis fails. Settings → Redis then shows Status: Not connected. The plugin’s README lists this constant as unsupported and warns that it will cause data corruption, so do not use it as the fix. If it is already set, the steps below still apply.

Step-by-step

  1. Copy the real error, then turn the cache off. Open https://example.com/wp-admin/ in your browser. The first line under the heading, in monospaced type, is the real error. Copy it.

    Now edit wp-config.php and add this line above the comment that says That's all, stop editing!:

    define( 'WP_REDIS_DISABLED', true );

    The drop-in stays in place but does nothing, and WordPress goes back to its built-in cache. Reload the site to confirm.

    If you cannot edit wp-config.php, rename the drop-in instead. This has the same effect:

    mv wp-content/object-cache.php wp-content/object-cache.php.off

    Either way, the built-in cache keeps nothing between requests. Pages are slower and the database works harder, so do not leave it this way.

  2. Find the message if you did not copy it. The plugin also writes every Redis error to the PHP error log. When WP_DEBUG and WP_DEBUG_LOG are both true, that log is wp-content/debug.log. Otherwise, use the path of your server’s PHP error log. Search it:

    grep -h "Exception: " wp-content/debug.log | tail -n 3

    Example output:

    [17-Nov-2026 13:52:08 UTC] RedisException: Connection refused in /home/acme/public_html/wp-content/object-cache.php:819

    The text between the colon and in / is the message. When the plugin uses the Predis client library instead of PhpRedis, the address follows the message, as in Connection refused [tcp://127.0.0.1:6379]. If the log has nothing, open Settings → Redis in the dashboard. While the plugin cannot connect or sign in, a red notice there reads “Redis is unreachable:”, followed by the message.

  3. Test Redis from the server. Print the connection settings that WordPress uses. The output includes the password, so do not paste it into a ticket:

    grep -E "WP_REDIS_(SCHEME|HOST|PORT|PATH|DATABASE|PASSWORD|USERNAME)" wp-config.php

    Example output:

    define( 'WP_REDIS_HOST', '127.0.0.1' );
    define( 'WP_REDIS_PORT', 6379 );
    define( 'WP_REDIS_DATABASE', 4 );

    A setting that is missing uses its default: scheme tcp, host 127.0.0.1, port 6379, database 0, no password. Now ask Redis for a reply with the same values. Use the first command for a host and port, and the second when WP_REDIS_PATH is set:

    redis-cli -h 127.0.0.1 -p 6379 ping
    redis-cli -s /run/redis/redis.sock ping

    PONG means Redis is up and accepts you. Any other answer is an error message to look up in the next step. Keep the same -h and -p, or -s, on every later redis-cli command. If WP_REDIS_PASSWORD is set, add --askpass and type that password. Without it, redis-cli answers NOAUTH even when WordPress signs in correctly.

  4. Match the message to its cause. Use the message from step 1, 2 or 3:

    Message containsWhat it meansGo to
    Connection refusedNothing listens at that address and portStep 5
    php_network_getaddressesThe host name does not resolveStep 5
    No such file or directoryThe socket file is not at that pathStep 6
    Permission deniedPHP is not allowed to open the socket fileStep 6
    NOAUTH, WRONGPASS or ERR AUTHThe password or user is wrongStep 7
    OOM command not allowedRedis is full and is not allowed to delete anythingStep 8
    MISCONFRedis failed to save to disk and now blocks writesStep 9
    LOADINGRedis is starting and still reading its dataStep 9
    read error on connection, Error while reading line or timed outRedis answered too slowlyTroubleshooting
  5. Start Redis, or correct the address. Check the service. It is named redis-server on Debian and Ubuntu, and redis on Red Hat, AlmaLinux and Rocky Linux, so use your system’s name in both commands:

    systemctl status redis-server
    journalctl -u redis-server --since "1 hour ago" | tail -n 20

    If the first one says inactive or failed, the second shows why Redis stopped. Start it with sudo systemctl start redis-server, then run the ping from step 3 again.

    If the service is active and the ping still fails, WordPress is using the wrong address. List where Redis listens:

    sudo ss -ltnp | grep redis

    Example output:

    LISTEN 0      511        127.0.0.1:6380       0.0.0.0:*    users:(("redis-server",pid=1482,fd=6))

    Here Redis listens on port 6380, so WP_REDIS_PORT must be 6380. The address 127.0.0.1 means that Redis accepts connections from the same server only. If Redis runs on another machine, the bind line in that machine’s redis.conf must include an address the web server can reach. Set a Redis password and restrict the port in the firewall before you open it that way.

    For php_network_getaddresses, run getent hosts followed by the value of WP_REDIS_HOST. If it prints nothing, the name does not resolve from this server.

  6. Repair the socket path or its permissions. Look at the socket file:

    ls -l /run/redis/redis.sock

    Example output:

    srwxrwx--- 1 redis redis 0 Nov 17 08:47 /run/redis/redis.sock

    If ls answers No such file or directory, compare the path with the unixsocket line in redis.conf, and set WP_REDIS_PATH to the real one. WP_REDIS_SCHEME must be unix. If the unixsocket line starts with #, Redis creates no socket at all.

    For Permission denied, read the left column. In the example, the owner redis and the group redis may use the socket, and nobody else. That matches unixsocketperm 770 in redis.conf. The user that runs PHP must be in that group. Add it, with your PHP user in place of acme, and test as that user:

    sudo usermod -aG redis acme
    sudo -u acme redis-cli -s /run/redis/redis.sock ping

    The second command must answer PONG. Then restart PHP-FPM, so that its running processes pick up the new group.

  7. Correct the password or the ACL user. Each message points to a different mismatch:

    • NOAUTH Authentication required. Redis has a password and WordPress sent none. Add WP_REDIS_PASSWORD to wp-config.php, above the That's all, stop editing! line. A constant defined below that line is read too late.
    • WRONGPASS invalid username-password pair or user is disabled. The password or user name is not the one Redis expects.
    • ERR AUTH <password> called without any password configured for the default user. WordPress sends a password, and Redis has none. If Redis should have one, put the requirepass line back in redis.conf and restart Redis. Otherwise, remove WP_REDIS_PASSWORD.

    For an ACL user, give the user name and the password as a pair:

    define( 'WP_REDIS_PASSWORD', [ 'wp_acme', 'your-redis-password' ] );

    Test the same pair from the shell. --askpass prompts for the password, so it stays out of your shell history:

    redis-cli --user wp_acme --askpass ping

    A message that starts with NOPERM means the user exists but is not allowed the command or the key. The Redis ACL documentation explains how to grant them.

  8. Free memory when Redis is full. Read the memory settings:

    redis-cli INFO memory | grep -E "used_memory_human|maxmemory_human|maxmemory_policy"

    Example output:

    used_memory_human:255.98M
    maxmemory_human:256.00M
    maxmemory_policy:noeviction

    maxmemory is the limit you gave Redis. maxmemory_policy says what Redis does at the limit. With noeviction, the default, it deletes nothing and refuses every write with the OOM message, which stands for “out of memory”. For a cache, tell Redis to delete the keys used least recently, then save the setting:

    redis-cli CONFIG SET maxmemory-policy allkeys-lru
    redis-cli CONFIG REWRITE

    Each command answers OK. If CONFIG REWRITE answers with an error, add maxmemory-policy allkeys-lru to redis.conf by hand, or the setting is lost at the next restart. Do this only when this Redis holds nothing but cache. If it also holds queues or sessions, allkeys-lru will delete those too. In that case, raise maxmemory or give the cache its own Redis. The Redis eviction documentation describes every policy.

  9. Clear a failed save, or wait for a restart to finish. MISCONF means the last background save to disk failed. With stop-writes-on-bgsave-error yes, the default, Redis then refuses writes. Check the save and find the folder it writes to:

    redis-cli INFO persistence | grep rdb_last_bgsave_status
    redis-cli CONFIG GET dir

    Example output:

    rdb_last_bgsave_status:err
    1) "dir"
    2) "/var/lib/redis"

    Run df -h /var/lib/redis to check for a full disk. Then read the Redis log from step 5 for a line such as Can't save in background: fork: Cannot allocate memory. Free disk space or memory, then run redis-cli BGSAVE, which answers Background saving started. Once the first command above prints rdb_last_bgsave_status:ok, Redis accepts writes again without a restart. Setting stop-writes-on-bgsave-error to no only hides the message: Redis then accepts data that it cannot save, and loses it at the next restart.

    LOADING Redis is loading the dataset in memory appears right after Redis starts. Wait, and repeat redis-cli INFO persistence | grep "^loading:". When it prints loading:0, Redis is ready.

  10. Turn the cache back on. Remove the WP_REDIS_DISABLED line from wp-config.php, or rename the file back to object-cache.php. Then empty the cache right away, because Redis may still hold values from before the outage:

    wp cache flush

    The answer is Success: The cache was flushed. This empties the whole Redis database, for every site that shares its number. If the command does not print that line, Redis is still failing: put the WP_REDIS_DISABLED line back and return to step 4.

Validate it works

Ask the plugin for its status, then load the site:

wp redis status | head -n 6
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/

Example output:

Status: Connected
Client: PhpRedis (v6.1.0)
Drop-in: Valid
Disabled: No
Ping: 1
Errors: []
200

You are done when the first line reads Status: Connected, Errors is empty and the site answers 200. Status: Disabled (via config constant) means the line from step 1 is still in wp-config.php. Status: Not enabled means the drop-in is missing; run wp redis enable to put it back.

Troubleshooting

  • read error on connection, Error while reading line or a message with timed out. By default, the plugin waits one second to connect and one second for each reply. If this shows up rarely, Redis was busy for a moment. If it persists, find out why Redis is slow before you raise the limits. Run redis-cli --latency for a few seconds, then press Ctrl+C. It prints the slowest reply as max, in milliseconds. For a delay you accept, such as a Redis on another machine, set WP_REDIS_TIMEOUT and WP_REDIS_READ_TIMEOUT above that figure. Both are in seconds, and 2 is a starting value, not a rule.
  • redis-cli answers PONG, and WordPress still fails. For a socket, test as the PHP user, as in step 6. If PHP runs in a container, 127.0.0.1 is the container itself, not the server where Redis runs.
  • The status reads Drop-in is invalid. Another caching plugin replaced object-cache.php with its own file. Turn off that plugin’s object cache, then run wp redis update-dropin.

When this is the wrong approach

On a managed host where Redis is part of the plan, you often cannot restart it or read its settings. Do step 1, then send the host the exact message from step 1 or 2. Ask for the current host and port or socket path, the password or ACL user, the database number, and the memory limit.

If Redis was never set up on this server, start with Redis object cache setup on cPanel. If the screen says “Error establishing a database connection”, the problem is MySQL, not Redis: see Error establishing a database connection.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.