How can I stop redis-server?

2019-01-15 23:49发布

I apparently have a redis-server instance running because when I try to start a new server by entering redis-server, I'm greeted with the following:

Opening port: bind: Address already in use

I can't figure out how to stop this server and start a new one.

Is there any command I can append to redis-server when I'm typing in the CLI?

My OS is Ubuntu 10.04.

21条回答
Ridiculous、
2楼-- · 2019-01-16 00:24

Another way could be :

brew services stop redis
查看更多
Fickle 薄情
3楼-- · 2019-01-16 00:25

Option 1: go to redis installation directory and navigate to src , in my case :

/opt/redis3/src/redis-cli -p 6379 shutdown

where 6379 is the default port.

Option 2: find redis process and kill

ps aux | grep redis-server

t6b3fg   22292  0.0  0.0 106360  1588 pts/0    S+   01:19   0:00 /bin/sh /sbin/service redis start
t6b3fg   22299  0.0  0.0  11340  1200 pts/0    S+   01:19   0:00 /bin/sh /etc/init.d/redis start

And Then initiate kill:

kill -9 22292

kill -9 22299

I'm using Centos 6.7 , x86_64

hope it helps

查看更多
趁早两清
4楼-- · 2019-01-16 00:27

On MacOSX,

This is what worked for me

/etc/init.d/redis restart

/etc/init.d/redis stop

/etc/init.d/redis start
查看更多
家丑人穷心不美
5楼-- · 2019-01-16 00:28

Another way could be:

ps -ef | grep -i 'redis-server'
kill -9 PID owned by redis

Works on *NIX & OSX

查看更多
6楼-- · 2019-01-16 00:28

I don't know specifically for redis, but for servers in general:

What OS or distribution? Often there will be a stop or /etc/init.d/... command that will be able to look up the existing pid in a pid file.

You can look up what process is already bound to the port with sudo netstat -nlpt (linux options; other netstat flavors will vary) and signal it to stop. I would not use kill -9 on a running server unless there really is no other signal or method to shut it down.

查看更多
来,给爷笑一个
7楼-- · 2019-01-16 00:29

Usually this problem arises after I shut down my computer ( or leaving running ) an irregular way.. I believe the port gets stuck open, while the process stops but continues to be bound to the previous port.

9/10 times the fix can be:

$ ps aux | grep redis

-> MyUser 2976  0.0  0.0  2459704    320   ??  S    Wed01PM   0:29.94 redis-server *:6379

$ kill 2976

$ redis-server

Good to go.

查看更多
登录 后发表回答