redis-server in ubuntu14.04: Bind address already in use
Asked Answered
S

17

89

I started redis server on ubuntu by typing this on terminal: $redis-server

This results in following > http://paste.ubuntu.com/12688632/

aruns ~ $ redis-server
27851:C 05 Oct 15:16:17.955 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
27851:M 05 Oct 15:16:17.957 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
27851:M 05 Oct 15:16:17.957 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
27851:M 05 Oct 15:16:17.958 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
27851:M 05 Oct 15:16:17.958 # Creating Server TCP listening socket *:6379: bind: Address already in use

How can I fix this problem, it there any manual or automated process to fix this binding.

Statistics answered 5/10, 2015 at 11:6 Comment(0)
S
150
sudo service redis-server stop
Spleen answered 18/7, 2019 at 5:38 Comment(3)
This one worked like a charm for me. I am just wondering why? What does it do differently than 'killall redis-server'?Manolete
I tired them all and this is the only one that worked for me on UbuntuFairtrade
This should have been the top commentUnthrone
C
148
$ ps aux | grep redis

Find the port that its running on.. In my case..

MyUser  8821   0.0  0.0  2459704    596   ??  S    4:54PM   0:03.40 redis-server *:6379

And then close the port manually

$ kill -9 8821

Re-run redis

$ redis-server
Clearway answered 29/7, 2016 at 14:21 Comment(2)
killall redis-server would be simpler.Rand
sudo service redis-server stop worked for meSalo
M
33

I solved this problem on Mac by just typing redis-cli shutdown, after this just re open the terminal and type redis-server and it will work .

Marieann answered 4/2, 2019 at 15:17 Comment(0)
D
17

for me, after lots of problems, this solved my issue:

 root@2c2379a99b47:/home/ ps -aux | grep redis
    redis     3044  0.0  0.0  37000  8780 ?        Ssl  14:59   0:00 /usr/bin/redis-server *:6379  

after finding redis, kill it!

root@2c2379a99b47:/home# sudo kill -9 3044
root@2c2379a99b47:/homek# sudo service redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server.
root@2c2379a99b47:/home# sudo service redis-server status 
redis-server is running
Drucilladrucy answered 9/4, 2016 at 15:39 Comment(1)
For some reason, I have several redis instances running, how do I stop all. Specifically the services that are running on ports 13000 and 11000Freehearted
R
12

This works for me:

$ killall redis-server

And combining everything in one line:

$ killall redis-server; redis-server
Rand answered 4/7, 2021 at 14:31 Comment(0)
T
9

So as it says, the process is already running so the best to do is to stop it, analyse and restart it and todo so here are the following commands :

redis-cli ping #should return 'PONG'

And this solved my issue:

$ ps -ef |grep redis

root      6622  4836  0 11:07 pts/0    00:00:00 grep redis
redis     6632     1  0 Jun23 ?        04:21:50 /usr/bin/redis-server *:6379

Locate redis process, and stop it!

$ kill -9 6632
$ service redis restart


Stopping redis-server: [  OK  ]
Starting redis-server: [  OK  ]


$ service redis status

Otherwise if all this doesn't work just try to type redis-cli

Hope it helps :)

Tarkington answered 3/5, 2019 at 15:2 Comment(0)
S
8

I read the documentation on http://www.redis.io , I opened the redis.conf file to configure the redis-server, its located at /etc/redis/redis.conf

$ sudo subl /etc/redis/redis.conf

Instead of sublime editor you can use editor of your choice, viz. nano, vi, emacs, vim, gedit.

In this file I uncommented the #bind 127.0.0.1 line. Hence, instead of 0.0.0.0:6379 now its 127.0.0.1:6379

Restart the redis server

$ sudo service redis-server restart

It will state, The server is now ready to accept connections on port 6379

This will put your server up, For any more detailed configuration and settings you can follow this redis-server on ubuntu

Statistics answered 5/10, 2015 at 11:27 Comment(0)
C
6

I prefer to use the command param -ef,

ps -ef|grep redis

the -efmeans

-A      Display information about other users' processes, including those
         without controlling terminals.
-e      Identical to -A.

-f      Display the uid, pid, parent pid, recent CPU usage, process start
        time, controlling tty, elapsed CPU usage, and the associated com-
        mand.  If the -u option is also used, display the user name
        rather then the numeric uid.  When -o or -O is used to add to the
        display following -f, the command field is not truncated as se-
        verely as it is in other formats.

then kill the pid

kill -9 $pid
Coen answered 22/12, 2018 at 3:47 Comment(0)
W
3

You may try

$ make

then

$ sudo cp src/redis-cli /usr/local/bin/ on terminal to install the redis and it's redis-cli command.

finally, you can use the redis-cli shutdown command. Hope this answer could help you.

Wellintentioned answered 6/9, 2019 at 8:36 Comment(0)
L
3

I am very late to answer this, but this is the solution worked for me, I think since I was using redis in docker, I could not fully kill the redis server. This is what helped me, firstly I stoped the redis server via the command

sudo systemctl stop redis

then run the redis server via the command

redis-server
Lexis answered 5/7, 2023 at 9:41 Comment(0)
C
1

Killing the process that was running after booting in the OS worked for me. To prevent redis from starting at startup in Ubuntu OS:

sudo systemctl disable redis-server
Chrissa answered 7/5, 2019 at 8:15 Comment(0)
R
1

In my case, I tried several times to kill the port manually and didn't work. So I took the easy path, reinstallation and worked like charm after that. If you're in Debian/Ubuntu:

sudo apt remove redis-server // No purge needed
sudo apt update
sudo apt install redis-server // Install once again
sudo systemctl status redis-server  // Check status of the service
redis-server    // initializes redis

Not the most technical-wise path, but nothing else worked.

Ragout answered 27/5, 2021 at 2:48 Comment(0)
S
1

This is worked for me:

killall redis-server
Sweater answered 4/9, 2023 at 8:29 Comment(0)
R
0

It may also happen if you installed Redis via snap and are trying to run it from somewhere else. If this is the case, you can stop the service via sudo snap stop redis.

Rapprochement answered 30/5, 2022 at 20:8 Comment(0)
J
0

I'm not sure, but when I first time installed redis and faced this message, turned out that's due to the redis-server first of all takes configure parameters or path/to/redis.conf, so when I passed nothing after "redis-server" it was trying to execute default redis.conf (bind 127.0.0.1, port 6379 ...) thereby overwrite the existing default redis.conf (which contains same "bind" and "port"!!). That's why I've seen this error, but it's possibly you have another reasons

Jollanta answered 14/9, 2022 at 23:54 Comment(0)
S
0

sudo service redis-server stop

Then

redis-server

This two command solved my issue

Susan answered 31/3, 2023 at 23:58 Comment(0)
G
-1

The problem shows that the default port that redis uses 6379is already in use by some other process. So simply change the port of redis server

redis-server --port 7000 will start a Redis server using port number 7000. and then redis-cli -p 7000 - Now use this to make your client listen at this port.

Gallicism answered 17/2, 2023 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.