"Error Establishing a Redis Connection" in WordPress: What It Means and How to Fix It
Fix "Error establishing a Redis connection" in WordPress: Redis stopped, wrong host or port after a migration, a leftover object-cache.php or memory.
On this page
- The error means object-cache.php tells WordPress to use Redis but Redis can't be reached; renaming that file brings the site back without losing data.
- Common causes are Redis stopped, the wrong host, port or socket in wp-config.php after a migration, or a drop-in left on a host without Redis.
- Check redis-cli ping, the connection constants, memory and the Redis log, then re-enable the object cache.
"Error establishing a Redis connection" means WordPress has an object cache drop-in (wp-content/object-cache.php) that tells it to use Redis, but it cannot reach the Redis server, usually because Redis has stopped, the host or port in wp-config.php is wrong after a migration, or the drop-in was left behind on a server without Redis.
Your posts and orders are safe. Redis only stores temporary copies of database results, so the quickest way to get the site back is to remove the drop-in; then fix Redis and switch caching back on.
Get the site back online first
- Open File Manager or SFTP and go to
/wp-content/. - Rename
object-cache.phptoobject-cache.php.off. WordPress now ignores Redis and reads straight from the database. - Load the site. It should work, a little slower than before. If it still fails, the error is something else; check error establishing a database connection, which is a different message about MySQL.
Find and fix the cause
- Check Redis is running. On a VPS, run
redis-cli ping. A reply ofPONGmeans Redis is up. No reply means start it withsudo systemctl start redis-server(the service may be namedredison some systems) and enable it at boot withsudo systemctl enable redis-server. On shared or managed hosting, check that Redis or "object cache" is still switched on in the panel, for example hPanel > Advanced or the host's caching page. - Check the connection settings. Open
wp-config.phpand look for lines likeWP_REDIS_HOST,WP_REDIS_PORT,WP_REDIS_PATH(for a Unix socket) andWP_REDIS_PASSWORD. After a move to new hosting these often still point at the old server. The usual local values are host127.0.0.1and port6379, but many hosts use a socket path or a custom port, so copy the exact values from the host's Redis page. - Check the database number and prefix if several sites share one Redis server. Two sites using the same database index and no prefix will overwrite each other's cache. Set a unique
WP_REDIS_PREFIX(orWP_CACHE_KEY_SALT) for each site. - Check Redis memory. If Redis is full and has no eviction policy, writes fail. Run
redis-cli info memoryand look atused_memory_humanagainstmaxmemory. Settingmaxmemory-policy allkeys-lruin the Redis config lets old keys drop out instead of failing. - Read the Redis log for crashes or out-of-memory kills, usually at
/var/log/redis/redis-server.logon Ubuntu. - Turn the cache back on. Rename
object-cache.php.offback, or in the Redis Object Cache plugin go to Settings > Redis and click Enable Object Cache. The status should say "Connected".
The error appears only some of the time
Intermittent Redis errors usually mean Redis is restarting, running out of memory, or taking too long to answer under load. Add a short timeout to wp-config.php, for example define( 'WP_REDIS_TIMEOUT', 1 ); and define( 'WP_REDIS_READ_TIMEOUT', 1 );, then check memory and the log as above. If it happens during backups, the server may be short of RAM for both jobs at once.
After a migration or a host change
This is the most common time to see the error. A backup or migration plugin copies object-cache.php along with everything else, but the new host may not have Redis at all, or has it on a different socket.
- If the new host has no Redis, delete
object-cache.phpand remove the Redis plugin, or switch to the host's own object cache if it has one. - If it does, update the host, port or socket path to the new values.
- Add this check to your move plan; our WordPress migration service includes it for every move.
Edge cases
- Two drop-ins fighting. LiteSpeed Cache, W3 Total Cache and the Redis Object Cache plugin can each write
object-cache.php. Use object caching in one plugin only. - Plugin removed, drop-in kept. Deleting the plugin doesn't always delete the drop-in. If the error appears after you "removed Redis", delete the file by hand.
- Docker setups. Inside a container
127.0.0.1means the container itself. Use the Redis service name from your compose file as the host.
If you're adding Redis for speed, it helps logged-in users, WooCommerce and busy admin screens most; see WooCommerce speed optimisation for where it fits.
FAQs
Will I lose data if I delete object-cache.php?
No. Redis holds only cached copies. Everything real is in the MySQL database.
Do I need Redis for WordPress?
No. Small brochure sites do fine with page caching alone. Redis helps sites with many logged-in users, stores and heavy admin use.
Why does the admin show "Not connected" in the Redis plugin?
The plugin can't reach Redis with the settings in wp-config.php. Check that the service is running and that host, port, socket and password match what your host gives.
Need help with your website?
I'm a freelance WordPress developer building fast, SEO-friendly websites since 2020. Tell me what you need and I'll reply with a plan and a fixed quote, usually within 24 hours.


