Redis won't connect with WP plugin
Closed this issue · 2 comments
When I added define('WP_REDIS_HOST', 'redis'); to my wp-config.php file, the Redis Object Cache settings page would stay "Status: Not Connected" after clicking the "Enable Object Cache" button.
Once I changed wp-config to define('WP_REDIS_HOST', '127.0.0.1'), the Redis Object Cache plugin setting page did show Status: Connected. I disconnected just to test again with "redis", wouldn't work, I put 127.0.0.1 again which now doesn't work anymore!
Kitematic shows the Redis container log with "the server is now ready to accept connections on port 6379." If I run "docker exec -it mywordpress_redis_1 redis-cli" from the command line, I do get a prompt showing "127.0.0.1:6379"
In the WP plugin the Servers table shows 1 entry:
Alias Protocol Host Port Database Password
Master TCP 127.0.0.1 6379 0 No
I then set a password under environment: in the docker-compose redis: service, followed by docker-compose up -d. I then added that same password to wp-config, now the plugin settings show:
Alias Protocol Host Port Database Password
Master TCP 127.0.0.1 6379 0 Yes
But I still can't connect. I also set WP_REDIS_PORT and WP_REDIS_DATABASE for good measure, no dice.
This is with Redis 3.2.3 and, Redis Object Cache 1.3.4 under WP 4.6.1, with a slightly modified version of your package (I run WP as a container from the wordpress-fpm image) under the latest Docker for Windows.
Hi @otravers,
define('WP_REDIS_HOST', 'redis');
It's a correct value of the Redis hostname, so it should work.
What's in the redis log docker-compose logs redis
?
Also, try to connect to the redis from the php.
# docker-compose exec php sh
# ping redis
PING redis (172.20.0.7): 56 data bytes
64 bytes from 172.20.0.7: seq=0 ttl=64 time=0.178 ms
64 bytes from 172.20.0.7: seq=1 ttl=64 time=0.120 ms
# telnet redis 6379
set testkey 10
get testkey
I deleted my Redis container, switched back to define('WP_REDIS_HOST', 'redis');, started again the Redis container, can now properly connect. Not sure what happened, sorry for the trouble and you can close this ticket.
Thanks also for your troubleshooting tips, I also installed this web interface to better see what's going on with Redis:
https://github.com/o/redis-info