After upgrading the PHP version of my Litespeed server from 7.4 to 8.2, I suddenly found that the Memcached and Redis connection tests in the Litespeed Cache plugin were failing (Connection Test: Failed).

This article explains how to detect and configure the cache Memcached (Redis) to resolve this issue.

Problem Description

On the Object Cache settings page of the Litespeed Cache plugin, the connection tests for Memcached and Redis show “Connection Test: Failed.” This is usually caused by the Memcached or Redis service not being installed or being configured incorrectly.

Solution

1. Install Memcached

First, make sure Memcached is installed on your GCP instance. Use the following commands to install Memcached:

sudo apt update sudo apt install memcached libmemcached-tools

2. Start and Enable the Memcached Cache Service

After installation, start and enable the Memcached service:

sudo systemctl start memcached sudo systemctl enable memcached

3. Check the Memcached Service Status

Confirm that the Memcached service has started and is running:

sudo systemctl status memcached

4. Configure Memcached

Edit the Memcached configuration file /etc/memcached.conf as needed, for example to set the memory size and listening port. Make sure the -l parameter is set to 127.0.0.1 or 0.0.0.0:

-l 127.0.0.1

5. Restart the Memcached Service

After modifying the configuration file, restart the Memcached service:

sudo systemctl restart memcached

6. Check Port Usage

Confirm that port 11211 is not occupied by another service:

sudo netstat -tuln | grep 11211

7. Confirm the Litespeed Cache Plugin Settings

In the WordPress admin panel, navigate to the settings page of the Litespeed Cache plugin, then check the Object Cache settings. Make sure the Memcached host is set to 127.0.0.1 and the port is set to 11211.

8. Test the Connection

On the Object Cache settings page of the Litespeed Cache plugin, perform a connection test. If the connection test succeeds, it should show “Connection Test: Passed.”

Causes of the Error

Common causes of a failed Memcached connection test include:

  1. Memcached service not installed or not running: You need to install and start the Memcached service.
  2. Incorrect configuration file: The -l parameter is set incorrectly, causing Memcached to fail to listen on the correct network interface.
  3. Port occupied: Port 11211 is occupied by another service, preventing Memcached from starting.
  4. Firewall settings: The firewall is blocking Memcached’s port, and the corresponding port needs to be opened.

By following the steps above, you should be able to successfully resolve the Memcached connection test failure. If you still have other issues, check the error logs or seek further help.

✦ Independent Journalism · Reader Support ✦

Support Independent Perspectives & In-Depth Insights

Every thoughtful analysis and candid critique comes from our dedication to truth and quality. We choose not to follow sensational algorithms or clickbait headlines.

Sustaining independent research requires reader support. Make a one-time or monthly contribution, securely processed by Google.

Payments secured by Google · Manage or cancel anytime in your Google Account