Error when starting Redis server: "Address already in use"

25,311

Solution 1

I had this same problems, but I forgot that redis persists. If you get this error, try this command:

redis-cli ping

And this solved my issue:

[root@tannetto tannetto]# ps -ef |grep redis
root      4871  4836  0 11:07 pts/0    00:00:00 grep redis
redis     4995     1  0 Jun23 ?        04:21:50 /usr/bin/redis-server *:6379

After finding redis, kill -9 it!

[root@tannetto tannetto]# kill -9 4995
[root@tannetto tannetto]# service redis restart
Stopping redis-server:                                     [  OK  ]
Starting redis-server:                                     [  OK  ]
[root@tannetto tannetto]# service redis status
redis-server (pid  4919) is running...

Solution 2

sudo service redis-server stop

Share:
25,311

Related videos on Youtube

Nomi
Author by

Nomi

Updated on September 18, 2022

Comments

  • Nomi
    Nomi over 1 year

    I am trying to install redis, according to the instructions here : https://redis.io/download, but getting the error :

    Creating Server TCP listening socket *:6379: bind: Address already in use

    when I run command ps -ef|grep redis i see :

    nomi      1168   947  0  2434 ?        00:00:00 grep --color=auto redis
    

    I type kill 1168 where 1168 is my PID and the process is not killed:

    "bash: kill: (1168) - No such process"

    next time i run the command ps -ef|grep redis i get diffrent PID number for example : 1170

    How can I remove this process?

    • Charles Green
      Charles Green over 6 years
      The output of your ps -ef | grep redis is simply showing the grep command, not a redis process. By the time you try to kill it, it has already stopped running. It appears that you have some other process listening to power 6379. Try sudo lsof -i -P -n | grep LISTEN to see what is using that port.
    • Nomi
      Nomi over 6 years
      I tried to run "sudo lsof -i -P -n | grep LISTEN" : but nothing appears
    • Charles Green
      Charles Green over 6 years
      Try sudo lsof -i -P -n | grep 6379 to check if something is attached to that particular socket
    • Nomi
      Nomi over 6 years
      no nothing is attached.
    • Charles Green
      Charles Green over 6 years
      How about netstat -tulpn
    • Nomi
      Nomi over 6 years
      it displays an empty table, I even tried to restart my computer and only run "redis" but still the same error
    • Charles Green
      Charles Green over 6 years
      This seems very strange - you may need to use 'sudo' to see the program names, but the netstat should show connections from dhclient, systemd-resolv and avahi-daemon at least.
  • Nomi
    Nomi over 6 years
    Thanks it worked , But I also had to install sudo apt-get install redis-server
  • lacostenycoder
    lacostenycoder about 2 years
    so easy and it worked thanks!