address already in use with redis-server
Asked Answered
R

4

6

When running the redis server, it shows address already in use This is the stacktrace:

45546:C 12 Jul 2019 10:04:41.888 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
45546:C 12 Jul 2019 10:04:41.888 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=45546, just started
45546:C 12 Jul 2019 10:04:41.888 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
45546:M 12 Jul 2019 10:04:41.889 * Increased maximum number of open files to 10032 (it was originally set to 256).
45546:M 12 Jul 2019 10:04:41.890 # Could not create server TCP listening socket *:6379: bind: Address already in use
Reichsmark answered 12/7, 2019 at 9:16 Comment(0)
P
18

The problem shows that the port is already in use by another process or is open in another window.

Change the port of redis server

redis-server --port 6360 will start a Redis server listening to port 6360.

redis-cli -p 6360 - Now use this to make your client listen at this port.

Hope this helps solve your problem

Pamper answered 12/7, 2019 at 9:21 Comment(2)
hi @Rajan, yes that really helps! but when i tried to do redis-cli -p 6360 . it threw back Could not connect to Redis at 127.0.0.1:6360: Connection refused not connected> redis-cli -p 6360 what would you think the problem is? :)Reichsmark
did the redis server start successfully on that port? start a fresh terminal and run the redis cli command.It works fine for me.Are you trying to connect through a program?Pamper
A
2

Rajan Sharma's answer is great and works fine, but if you wondering how to make this work with supervisord check here: redis-server-ubuntu.

You can use Rajan's answer but it's better to change the port in redis config file, lacated: /etc/redis/redis.conf, example using nano editor:

sudo nano /etc/redis/redis.conf

and locate this line:

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379

and change port number to what you want, example 6360 as above and save ti. Then restart the redis service:

sudo systemctl restart redis.service

Finally check the redis service is active:

sudo systemctl status redis
Aggregate answered 2/8, 2022 at 19:55 Comment(0)
T
0

Solution by @Ranjan will work,

If you want to debug further and see which process is using that port can be done by below

netstat -antp | grep 6379
Tradition answered 12/7, 2019 at 15:59 Comment(0)
S
0

Make new copy of.config files and change the port and use that file

I have faced this issue when I was using Redis in windows. And the root cause was when I have installed Redis from a msi installer it created a service which kept running in background and I was not aware of that.

So when ever I try to start this service manully with default config I got the same error but after creating a new copy of config file with l changed port it worked for me.

Solidify answered 16/7, 2019 at 18:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.