• Resolved Deepak

    (@d88pak)


    Hi,

    I have WordPress and Redis running on docker containers separately (with same network name using docker-compose.yml). Redis Object Cache plugin is installed on my WordPress. When I enable this plugin Redis refuses to connect. I don’t have much experience with wordpress/redis either. Need some guidance to point me in right direction. I am trying to setup woocommerce in container and speed up a bit with Redis.

    Here are some diagnostic data:

    Status: Not connected
    Client: 
    Drop-in: Valid
    Disabled: No
    Ping: 
    Connection Exception: Connection refused [tcp://127.0.0.1:6379] (Predis\Connection\ConnectionException)
    Errors: [
        "Connection refused [tcp:\/\/127.0.0.1:6379]"
    ]
    PhpRedis: Not loaded
    Predis: 1.1.6
    Credis: Not loaded
    PHP Version: 7.4.13
    Plugin Version: 2.0.17
    Redis Version: Unknown
    Multisite: No
    Filesystem: Working
    Global Prefix: "wp_"
    Blog Prefix: "wp_"

    Thanks!

    • This topic was modified 3 years, 11 months ago by Deepak.
    • This topic was modified 3 years, 11 months ago by Deepak.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Deepak

    (@d88pak)

    Solved now with following:

    define( 'WP_REDIS_HOST', 'redis' );
    define( 'WP_REDIS_PORT', 6379 );
    Plugin Author Till Krüss

    (@tillkruess)

    I don’t provide support for Docker environments.

    What I can suggest is creating a single PHP file and test the connection to Redis from PHP itself in your environment:

    
    $redis = new Redis;
    $redis->connect('redis', 6379, 2.0);
    
    var_dump($redis->ping());
    
    

    If you don’t have PhpRedis installed, you’d need something like this:

    
    require 'Predis/Autoloader.php';
    
    Predis\Autoloader::register();
    
    $redis = new Predis\Client([
        'scheme' => 'tcp',
        'host' => 'redis',
        'port' => 6379,
    ]);
    
    var_dump($redis->ping());
    

    The reason for this problem is that the docker container has an independent IP address when it is running. You need to set the host to the IP address of the container.
    The command to view the container IP address is: docker inspect containerName –format='{{.NetworkSettings.IPAddress}}’

    • This reply was modified 3 years, 8 months ago by Roast Coffee.

    I have the same issue

    Status: Not connected
    Client: PhpRedis (v5.1.1)
    Drop-in: Valid
    Disabled: No
    Ping: 
    Errors: [
        "Connection refused"
    ]
    PhpRedis: 5.1.1
    Predis: Not loaded
    Credis: Not loaded
    PHP Version: 7.4.2
    Plugin Version: 2.0.17
    Redis Version: Unknown
    Multisite: No
    Filesystem: Working
    Global Prefix: "cms_wp_"
    Blog Prefix: "cms_wp_"
    WP_REDIS_HOST: "redis"
    WP_REDIS_PORT: 6379
    WP_REDIS_PASSWORD: ????????
    Global Groups: [
        "blog-details",
        "blog-id-cache",
        "blog-lookup",
        "global-posts",
        "networks",
        "rss",
        "sites",
        "site-details",
        "site-lookup",
        "site-options",
        "site-transient",
        "users",
        "useremail",
        "userlogins",
        "usermeta",
        "user_meta",
        "userslugs",
        "redis-cache"
    ]
    Ignored Groups: [
        "counts",
        "plugins",
        "themes",
        "blog-details",
        "blog-id-cache",
        "blog-lookup",
        "global-posts",
        "networks",
        "rss",
        "sites",
        "site-details",
        "site-lookup",
        "site-options",
        "site-transient",
        "users",
        "useremail",
        "userlogins",
        "usermeta",
        "user_meta",
        "userslugs",
        "redis-cache",
        "blog_meta"
    ]
    Unflushable Groups: []
    Drop-ins: [
        "advanced-cache.php v by ",
        "Redis Object Cache Drop-In v2.0.17 by Till Krüss"
    ]

    Here are the details of my container:

    "NetworkSettings": {
                "Bridge": "",
                "SandboxID": "f7e726af4087f62e585ec6aa5a5f20708ac27d209b5a770f64a608a02457c422",
                "HairpinMode": false,
                "LinkLocalIPv6Address": "",
                "LinkLocalIPv6PrefixLen": 0,
                "Ports": {
                    "6379/tcp": null
                },
                "SandboxKey": "/var/run/docker/netns/f7e726af4087",
                "SecondaryIPAddresses": null,
                "SecondaryIPv6Addresses": null,
                "EndpointID": "",
                "Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAddress": "",
                "IPPrefixLen": 0,
                "IPv6Gateway": "",
                "MacAddress": "",
                "Networks": {
                    "local-network": {
                        "IPAMConfig": null,
                        "Links": null,
                        "Aliases": [
                            "redis",
                            "9baf69f42063"
                        ],
                        "NetworkID": "1a584de10c2df3aa766d5ef30680880eea5a4abac120c1c6887c797793799a78",
                        "EndpointID": "f36353fdecacbe1f8220dce3c15adbe61cf307589e6d69ea01a2b71313c47aae",
                        "Gateway": "172.20.0.1",
                        "IPAddress": "172.20.0.2",
                        "IPPrefixLen": 16,
                        "IPv6Gateway": "",
                        "GlobalIPv6Address": "",
                        "GlobalIPv6PrefixLen": 0,
                        "MacAddress": "02:42:ac:14:00:02",
                        "DriverOpts": null
                    }
                }
            }

    Seems to be a problem of the plugin, because I can connect from php cli without problems (and authenticate too)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Connection Refused for Dockerized WordPress and Redis’ is closed to new replies.