3

For the past few weeks I have been using a redis server locally on Windows 10 using WSL 2/Ubuntu 20.04 and now suddenly I can't connect to the server anymore. Here is what I usually did in linux terminal that opens when you run ubuntu using wsl 2:

$ sudo service redis-server start
$ sudo service redis-server status
* redis-server running

But now if I try to run the redis-cli command I get this error:

Could not connect to Redis at 127.0.0.1:6379: Network is unreachable

I have checked the ip and port using:

$ ps aux | grep redis

which returns

redis      190  0.2  0.0  51704  9796 ?        Ssl  17:12   0:00 /usr/bin/redis-server 127.0.0.1:6379

From what I can tell this is telling me that the server is running at 127.0.0.1:6379 yet I cannot connect to it. Every post I can find on this kind of issue shows the error as

Could not connect to Redis at 127.0.0.1:6379: Connection Refused

instead of "network is unreachable" so I'm not sure what the issue is.

Timaayy
  • 790
  • 5
  • 19
  • Sounds like you have no loopback interface. Check `ifconfig`. You can try running `sudo ifconfig lo 127.0.0.1 && sudo route add -net 127.0.0.0` to fix it, but normally the OS set this up automatically, so maybe something else is messed up in your system as well... – CherryDT Aug 14 '20 at 15:32
  • I tried to use ifconfig but had to use ```sudo apt install net-tools``` to use ifconfig. The install failed. The error I get: ```E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60+git20180626.aebd88e-1ubuntu1_am``` --- so I can't use ifconfig – Timaayy Aug 14 '20 at 16:47

1 Answers1

1

The issues is with Firewall settings its either windows Firewall or else WSL Ubuntu Firewall which refuse to connect via port.

Opening Port :

Windows : https://www.windowscentral.com/how-open-port-windows-firewall

Ubuntu (WSL) : sudo ufw allow <port number>

Other linux distor refer : https://www.journaldev.com/34113/opening-a-port-on-linux

This Solved the issue for me.

Jaikishore
  • 111
  • 2
  • 6