I am running Ubuntu 15.10 and already have memcached installed on my system. My current project requirement is to run two instances of memcached on the same server but with different ports. I start with /etc/memcached.conf file and check that it has option of specifying the port number. So, I thought I just need to have two identical conf files with different port numbers.

Then I check the memcached start up script /etc/init.d/memcached so that I could specify the location of the conf files. But to my surprise I see that the start up script already has an option to run multiple memcached instances.

# Usage:
# cp /etc/memcached.conf /etc/memcached_server1.conf
# cp /etc/memcached.conf /etc/memcached_server2.conf
# start all instances:
# /etc/init.d/memcached start
# start one instance:
# /etc/init.d/memcached start server1
# stop all instances:
# /etc/init.d/memcached stop
# stop one instance:
# /etc/init.d/memcached stop server1
# There is no "status" command.

# check for alternative config schema
if [ -r "${FILES[0]}" ]; then

I tried the above option, but it still keeps starting a single instance, instead of starting two instances. Am I missing something here ?

4 Answers 4


As Robert Bihlmeyer said on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=784357#13, a simple solution is to remove /lib/systemd/system/memcached.service.

Without this file, the systemd falls back on /etc/init.d/memcached, which supports multiple configurations.

I confirmed this problem on Ubuntu 16.04 and solved it this way.

  • 1
    Unfortunately it reappears after some time, maybe with updates... How to make sure it will not be recreated?
    – the_nuts
    Apr 15, 2018 at 21:14

This can easily be done by creating a file /lib/systemd/system/[email protected] with basically the same contents as the memcached.service file with a few small changes:

Description=memcached daemon for %i

ExecStart=/usr/share/memcached/scripts/systemd-memcached-wrapper /etc/memcached_%i.conf


You can then use systemctl to manage each service individually:

systemctl enable memcached@server1

systemctl start memcached@server2
  • 1
    Suitable (with modifications) for RedHat, CentOS, etc. Just be sure to disable the "main" one: systemctl disable memcached
    – Otheus
    Nov 13, 2018 at 14:29
  • [email protected] file should be better in /etc/systemd/system directory. As explained at systemd file hierarchy /lib and /usr/lib are for private vendor data (distro files). System configurations should go better in /etc.
    – David
    Nov 14, 2018 at 21:55

Having the same issue in Debian Jessie. Will report back if I find a solution.

In the mean time you can manually start the services to achieve the desired result.


sudo /etc/init.d/memcached stop
memcached -d -m 64 -l -p 11211 -u memcache
memcached -d -m 64 -l -p 11211 -u memcache

Update 1: Aha! There is a bug in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=784357. Could this also affect Ubuntu?


Run the follow command to configure multiple Memcached instances on ubuntu 16.04 server

sudo cp /etc/memcached.conf /etc/memcached_11212.conf

sudo vim /etc/memcached_11212.conf

Note: change the port from 11211 to 11212 or another port which you want.

sudo cp /lib/systemd/system/memcached.service /lib/systemd/system/memcached2.service

sudo vim /lib/systemd/system/memcached2.service

Note: change /etc/memcached.conf to /etc/memcached_11212.conf

sudo systemctl start memcached2.service

sudo systemctl status memcached2.service

sudo netstat -tulpan | grep memcached

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .