Skip to content
Runbook

Install Memcached on Ubuntu / Debian

High-performance, distributed in-memory cache for key-value data.

Cachecachein-memorykey-valuedistributed

Installation

Server (Ubuntu repositories) · apt
sudo apt update
sudo apt install -y memcached libmemcached-tools

libmemcached-tools adds helpers like memcstat and memcdump.

Verify the installation

Verify
memcached -V

Service

Start
sudo systemctl start memcached
Stop
sudo systemctl stop memcached
Status
sudo systemctl status memcached
Restart
sudo systemctl restart memcached
On boot
sudo systemctl enable memcached

Important files

TypePathDescription
config/etc/memcached.confService configuration: memory (-m), listen address (-l), port (-p).

Default ports

11211

Command-line tools

  • memcachedThe cache server daemon.
  • memcstatQuery server statistics (from libmemcached-tools).
  • memcdumpDump the list of keys (from libmemcached-tools).

Uninstall

Uninstall
sudo apt purge -y memcached libmemcached-tools
sudo apt autoremove -y

Good to know

  • Ubuntu's default /etc/memcached.conf binds to 127.0.0.1 (-l 127.0.0.1) — keep it that way unless you firewall the port.
  • Set the cache size with the -m line (megabytes) in /etc/memcached.conf, then restart the service.
  • Memcached has no authentication; never expose port 11211 to untrusted networks.

Installation on Ubuntu

sudo apt install -y memcached libmemcached-tools installs the server and a few helper tools, and registers the memcached systemd service started automatically. Verify the binary with memcached -V.

Configuration

Unlike on macOS, Ubuntu provides /etc/memcached.conf, where each line is a flag: -m 64 (memory in MB), -l 127.0.0.1 (listen address), -p 11211 (port). Edit it, then sudo systemctl restart memcached to apply.

Security

The default config binds to 127.0.0.1, which is the safe choice — Memcached has no authentication. If you must listen on a LAN address, restrict access with a firewall and disable UDP (-U 0) to avoid amplification abuse.