How to install Memcached on Debian 10

Memcached is a free, open source, high-performance, in-memory key-value data store. It is commonly used to speed up applications by caching various objects from API results and database calls.

This article shows you how to install and configure Memcached on Debian 10.


You will need to be logged in as a user with sudo access to be able to install packages on your Debian system.

Installing Memcached on Debian 10

The memcached package is included by default in the Ubuntu 20.04 repositories. To install it, enter the following command as root or a user with sudo privileges:

sudo apt update
sudo apt install memcached libmemcached-tools

The libmemcached-tools package provides several command line tools for interacting with the Memcached server.

After the installation is complete, Memcached will start automatically. You can verify this by checking the status of the service:

sudo systemctl status memcached

The result will look like this:

● memcached.service - memcached daemon
   Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-08-14 14:22:01 CDT; 3min 40s ago
     Docs: man:memcached(1)

That’s all. You have successfully installed Memcached on your Debian 10 server.

Memcached setup

Memcached options can be configured in the /etc/memcached.conf file. For most users, the default configuration settings are sufficient.

Remote access

Memcached only listens on the local host. If the client connecting to the server is also running on the same host, then you don’t need to change the default config file.

If configured incorrectly, Memcached can be used to perform a distributed denial of service (DDoS) attack. To allow remote connections to the Memcached server, you need to configure your firewall and only allow trusted clients to access UDP port 11211 of Memcached.

The following example assumes that you are connecting to the Memcached server over a private network. Server IP and Client IP

The first step is to edit the memcached configuration and configure the service to listen on the server’s private network interface:

To do this, open the memcached.conf configuration file:

sudo nano /etc/memcached.conf

Find the line that starts with -l and replace with the server’s IP address



Restart the Memcached service for the changes to take effect:

sudo systemctl restart memcached

After configuring the service, the next step is to open the memcached port in the firewall.

sudo ufw allow from to any port 11211

You can now connect to the Memcached server from a remote location.

Memcached connection

There are many memcached client implementations written for different programming languages.


To use Memcached as a caching database for your PHP application like WordPress, Drupal or Magento, you need to install the php-memcached extension:

sudo apt install php-memcached


There are several Python libraries for interacting with memcache. You can install your preferred library using pip:

pip install pymemcache

pip install python-memcached


We showed you how to install Memcached on Debian 10. For more information on this topic, see the Memcached Wiki.

If you have any questions or feedback, feel free to leave comments below.