Issue with Memcached connection failed (LiteSpeed Cache on Wordpress)

#1
Hi folks,
I installed the OLS Wordpress Image as found on Microsoft Azure platform.

I recently migrated a Wordpress site from another server, which also had LiteSpeed Cache plug-in on it.

I see that on the new server Memcached is not connection. Has "Connection Failed" error in the LiteSpeed Cache plug-in.

I've run
```nc -U /var/www/memcached.sock
stats
```
And see no errors.

When I check the memcached status, it is running, but there's a permissions issue on `/var/run/memcached/memcached.pid.tmp`. Output was:

```
memcached.service - memcached daemon
Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-08-02 01:03:17 UTC; 8min ago
Docs: man:memcached(1)
Main PID: 27311 (memcached)
Tasks: 10 (limit: 4674)
CGroup: /system.slice/memcached.service
└─27311 /usr/bin/memcached -m 64 -p 11211 -u www-data -l 127.0.0.1 -P /var/run/memcached/memcached.pid -s /var/www/memcached.sock -a 0770 -p /tmp/memcached.pid

Aug 02 01:03:17 VMWordPress1 systemd[1]: Started memcached daemon.
Aug 02 01:03:17 VMWordPress1 systemd-memcached-wrapper[27311]: Could not open the pid file /var/run/memcached/memcached.pid.tmp for writing: Permission denied
```
I tried setting the host (in cache plugin) to `/var/www/memcached.sock` but that didn't help.

Issue appears to be exactly the same as what was reported here. But unfortunately the OP doesn't state what he/she did to fix it, just that is started working.

What's the correct permissions for `/var/run/memcached/memcached.pid.tmp`? Is it just a matter of getting the corrected, or is something else required?

I've disabled and enabled the cache plug-in. Didn't help.
 
#2
I should add, that what got me looking into this was a lot of instances of the following warning in the OLS error logs. I am not sure it's related, but suspect it is. Your thoughts?

```
[STDERR] objectcache.critical: Failed to locate and load object cache API.
```
 
#3
UPDATE
I had previous tried using `/var/www/memcached.sock` in the host setting, multiple times, but it made no difference. However, I tried again just now, and it still didn't help. But then I stopped and then started the memcached server (as part of something else I was trying out for fixing it), and after that the connection was successful.

I am not entirely sure if that chain of events caused it to resolve.

1659404473643.png
 
Top