1

Here is my test code:

$host = 'localhost';
$port = '11211';

if (extension_loaded('memcached')) {
    $mc = new Memcached;
    $mc->addServer($host, $port);
    if ($mc->set('test', 'TEST')) {
        echo 'true';
    } else {
        echo $mc->getResultCode();
        echo $mc->getResultMessage();
    }
} else {
    echo 'no_memcached';
}

The output is:

47 SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY

SELinux is disabled, I've also tried to turn off tcp_nodelay in nginx.conf and tried different types of host (127.0.0.1 and localhost) and ports.

I've read this question - How to debug memcached "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY" errors?

But nothing helped and I cannot comment, because I have not enough points.

bigboy
  • 11
  • 2
  • theres an additional one: https://serverfault.com/questions/64007/failed-to-connect-to-memcache-host?rq=1 and however, verify that the server is started – djdomi Aug 05 '21 at 14:58

2 Answers2

1

It can be different problems why it's not run.

In my case, I realized that memcached service is not started in docker container.

So, first - check if memcached actually works and check it logs. Try to connect to memcached (on default location)

telnet localhost 11211
Dave M
  • 4,514
  • 22
  • 31
  • 30
Taras Budzyn
  • 111
  • 2
0

The solution was simple.

Memcached was installed as a PHP module, but not as a Debian extension.

To install it, just run two commands:

sudo apt update
sudo apt install memcached

Done. All works now.

bigboy
  • 11
  • 2