How to Install Memcached on Debian 10

Memcached is a high performance free and opensource in-memory key-value store used as a caching system. It’s mainly used for speeding up database-driven sites and web applications by caching data in RAM. In so doing, it significantly reduces the frequency that an eternal source of data is read.

Memcached is simple and easy to deploy and its API is widely available for a wide range of popular programming languages such as Python.

This guide walks you through the installation of Memcached on Debian 10, codenamed Debian Buster and Debian 9, codenamed Stretch.

Install Memcached on Debian

Memcached packages are already included in the Debian repository, and as such, we are going to install Memcached using the APT package manager.

But first, update system packages as shown:

$ sudo apt update

Thereafter, install Memcached by invoking the command:

$ sudo apt install memcached libmemcached-tools

The libmemcached-tools package is a C & C++ library that provides multiple command-line utilities that you can use for interacting and managing the Memcached server.

Install Memcached in Debian 10
Install Memcached in Debian 10

Once the installed, Memcached service will automatically start and you can verify this by running the command:

$ sudo systemctl status memcached
Check Memcached Status
Check Memcached Status

By default, Memcached listens on port 11211 and you can verify this using the netstat command as shown:

$ sudo netstat -pnltu
Check Memcached Port
Check Memcached Port

Configure Memcached on Debian

To configure Memcached, you need to configure the /etc/memcached.conf file. For the most part, the default settings will work just fine for a majority of users.

Without any configuration, Memcached listens on the localhost only. If you are connecting to the Memcached server from the server itself, no configuration is needed.

To allow remote connections to the server, some additional configuration is required. We need to modify the firewall to allow access to UDP port 11211 which Memcached listens to by default.

Let’s assume that the Memcached server IP address is and the client’s IP address is To allows the client machine access to the Memcached server, run the command.

$ sudo ufw allow from to any port 11211

Next, reload the firewall for the changes to persist.

$ sudo ufw reload

Thereafter, head over to the memcached.conf configuration file.

$ sudo vim /etc/memcached.conf

Be sure to locate the line that starts with -l

Memcached Enabled for Localhost
Memcached Enabled for Localhost

Replace it with the server’s IP, which in this case is as shown:

Enable Remote Memcached Access
Enable Remote Memcached Access

Now, restart Memcached for the changes to come into effect.

$ sudo systemctl restart memcached

Enable Memcached for PHP and Python Applications

If you intend to use Memcached as a caching database for PHP applications such as Drupal or WordPress, the php-memcached extension is required.

To install it, run the command:

$ sudo apt install php-memcached
Install PHP-Memcached in Debian 10
Install PHP-Memcached in Debian 10

For Python applications, install the following Python libraries using pip. If pip is not installed, you can install it using the command:

$ sudo apt install python3-pip

Then install the libraries as shown.

$ pip3 install pymemcache
$ pip3 install python-memcached

We have come to the end of this guide. It’s our hope that you can now install Memcached on your Debian 10 instance without a hitch. Your feedback is welcome.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.