How to stop and restart memcached server 1.4.5 in linux OS from command line?
-
can anybody help me in this https://stackoverflow.com/questions/50135302/memcached-could-not-connect-to-remote-server-memcached-js – Rituraj RF N TF May 07 '18 at 12:13
12 Answers
Using root, try something like this:
/etc/init.d/memcached restart
-
it did not work- is there a need to creare script to stop and start as service? – smriti Jun 23 '10 at 15:56
-
3well, it realy depends on your linux distribution and how you did install memcache. If you hav installed package of your distribution there should be memcached start/stop script (maybe it is in different directory like /etc/rc.d) If you installed memcached manualy you probably need also create star/stop script by yourself. – pejuko Jun 23 '10 at 17:11
-
Log in as root or do
su -
Then:
service memcached restart
If that doesn't work, then:
/etc/init.d/memcached restart
It all depends on which Linux distro (or other OS) you're using.

- 14,854
- 11
- 100
- 103

- 7,419
- 9
- 51
- 64
-
btw the dash after su is important, without it, it will report it can't find "service" – ajacian81 Dec 17 '11 at 23:51
-
2This was the correct answer for me, running Ubuntu and memcached as a service. Without specificing service, it does not work. – user658182 Aug 05 '12 at 14:08
-
2If you don't have root, but sudo privileges: `sudo service memcached restart` – danriti Feb 27 '13 at 15:32
-
-
If you're using homebrew:
brew services restart memcached

- 7,721
- 2
- 38
- 38
-
Note that `services` is now considered an external tool to brew. http://apple.stackexchange.com/questions/150300/need-help-using-homebrew-services-command – Kirby May 06 '15 at 21:54
-
...meaning you need to install it before you can use it: `brew tap homebrew/services` – wxactly Sep 23 '15 at 00:26
sudo service memcached stop
sudo service memcached start
sudo service memcached restart

- 14,231
- 7
- 51
- 45
if linux
if install by apt-get
service memcached stop
service memcached restart
if install by source code
Usage: /etc/init.d/memcached {start|stop|restart|force-reload|status}
can also simply kill $pid to stop

- 131
- 1
- 3
As root on CentOS 7:
systemctl start memcached
systemctl stop memcached
systemctl restart memcached
To tell the service to start at reboot (ex chkconfig):
systemctl enable memcached
To tell the service to not start at reboot:
systemctl disable memcached

- 1,659
- 16
- 20
To shutdown memcache daemon:
sudo service memcached stop
To start memcached daemon:
sudo service memcached start
Restart memcached server:
sudo service memcached restart
You can see if Memcache is currently runing:
sudo ps -e | grep memcached
And you can check the TCP or UDP ports if something (e.g. Memcache) is listening to it:
netstat -ap | grep TheChosenPort#
netstat -ap | grep 11211
For some Linuxes you need to change your commands like:
sudo /etc/init.d/memcached start
sudo /etc/init.d/memcached restart
sudo /etc/init.d/memcached stop

- 2,356
- 28
- 39
If you want to be allowed to shutdown the memcached server you can give it that option before start it :
memcached -A &
With this option when you connect to memcached server for example:
telnet localhost 11211
then you can use shutdown
command to shutdown the server. You can also shutdown the memcached server when it is run as a process, first find the process PID using:
pidof memcached
then use:
kill PID command

- 45,791
- 17
- 81
- 97

- 744
- 7
- 11
If you have an older version of memcached and need a script to wrap memcached as a service, here it is: Memcached Service Script

- 4,972
- 3
- 25
- 39
For me, I installed it on a Mac via Homebrew and it is not set up as a service. To run the memcached
server, I simply execute memcached -d
. This will establish Memcached server on the default port, 11211.
> memcached -d
> telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
version
VERSION 1.4.20

- 15,127
- 10
- 89
- 104
-
1You can use the -d switch to launch memcached as a daemon (bit cleaner than backgrounding it) – carpii Jun 23 '15 at 00:19
-
2