WSL: redis-cli cannot connect to redis-server.

I can sudo apt-get install redis-server with no errors. I can start redis-server either with redis-server --daemonize yes or redis-server &, but when I run redis-cli I get Could not connect to Redis at 127.0.0.1:6379: Connection refused.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Worth noting, if you’re in production, you might want to run Redis in the background:

redis-server --daemonize yes

Had the same issues trying to start redis-server from the command line. What did work was starting the redis-server which was installed, but not started, automatically.

russ@RUSSALEX-DESK:/mnt/d/dev/scripts$ sudo service redis-server start
Starting redis-server: redis-server.
russ@RUSSALEX-DESK:/mnt/d/dev/scripts$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

In the past, I have built Redis myself (generally follow these instructions) and had good luck running from the command line there. Haven’t had a chance to try this on a straight Ubuntu VM, but it should get you moving.

leep@NEONANTWERP:~$ redis-server --daemonize yes
leep@NEONANTWERP:~$ ps aux | grep redis-server
leep       202  0.0  0.0      0     0 ?        Ssl   2431   0:00 redis-server *:6379
leep       206  0.0  0.0      0     0 ?        S     2431   0:00 grep --color=auto redis-server
leep@NEONANTWERP:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
leep@NEONANTWERP:~$ sudo kill 202
leep@NEONANTWERP:~$
leep@NEONANTWERP:~$
leep@NEONANTWERP:~$ redis-server &
[1] 210
leep@NEONANTWERP:~$ 210:C 14 May 03:55:20.325 # Warning: no config file specified, using the defa
ult config. In order to specify a config file use redis-server /path/to/redis.conf
210:M 14 May 03:55:20.326 # You requested maxclients of 10000 requiring at least 10032 max file d
escriptors.
210:M 14 May 03:55:20.326 # Redis can't set maximum open files to 10032 because of OS error: Inva
lid argument.
210:M 14 May 03:55:20.326 # Current maximum open files is 2048. maxclients has been reduced to 20
16 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 210
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

210:M 14 May 03:55:20.328 # Server started, Redis version 3.0.7
210:M 14 May 03:55:20.329 * DB loaded from disk: 0.001 seconds
210:M 14 May 03:55:20.329 * The server is now ready to accept connections on port 6379

leep@NEONANTWERP:~$ ps aux | grep redis-server
leep       210  0.0  0.0      0     0 ?        Sl    2431   0:00 redis-server
leep       214  0.0  0.0      0     0 ?        S     2431   0:00 grep --color=auto redis-server
leep@NEONANTWERP:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
leep@NEONANTWERP:~$ sudo kill 210
210:signal-handler (1463198152) Received SIGTERM scheduling shutdown...
leep@NEONANTWERP:~$ 210:M 14 May 03:55:52.971 # User requested shutdown...
210:M 14 May 03:55:52.971 * Saving the final RDB snapshot before exiting.
210:M 14 May 03:55:52.975 * DB saved on disk
210:M 14 May 03:55:52.975 # Redis is now ready to exit, bye bye...

[1]+  Done                    redis-server
leep@NEONANTWERP:~$

Gah! This just bit me too … MUST MANUALLY START REDIS-SERVER FIRST! 😒

  1. Delete all bind lines except the one you must have (one line many ip addresses, you should have)
    bind 127.0.0.1 192.168.99.1 ::1
  1. You should close protected mode I believe. In the configuration, set
    protected-mode no

Faced same issue for 02 days. The workaround is first start the redis-server manually and then start the service. If you miss either of two, it shows Connection refused error.

Step 1: Run redis-server --daemonize yes Step 2: Run sudo service redis-server start or sudo service redis-server restart

Ok, Congratulation 😄 ! I solve my problem through stop svchost.exe! default

But i don’t want stop my svchost.exe that is about IPV6 NAT(Window system sevice)

If can i change port 6379 used by svchost.exe to others?

@doncadavona Thank you, I have successfully solved the problem!