【发布时间】:2020-12-04 12:19:31
【问题描述】:
在过去的几周里,我一直在使用 WSL 2/Ubuntu 20.04 在 Windows 10 上本地使用 redis 服务器,但现在我突然无法再连接到服务器了。这是我通常在使用 wsl 2 运行 ubuntu 时打开的 linux 终端中所做的:
$ sudo service redis-server start
$ sudo service redis-server status
* redis-server running
但现在如果我尝试运行 redis-cli 命令,我会收到以下错误:
Could not connect to Redis at 127.0.0.1:6379: Network is unreachable
我已经检查了 ip 和端口使用:
$ ps aux | grep redis
返回
redis 190 0.2 0.0 51704 9796 ? Ssl 17:12 0:00 /usr/bin/redis-server 127.0.0.1:6379
据我所知,这告诉我服务器正在 127.0.0.1:6379 运行,但我无法连接到它。 我能找到的关于此类问题的每篇文章都将错误显示为
Could not connect to Redis at 127.0.0.1:6379: Connection Refused
而不是“网络无法访问”,所以我不确定问题是什么。
【问题讨论】:
-
听起来你没有环回接口。检查
ifconfig。您可以尝试运行sudo ifconfig lo 127.0.0.1 && sudo route add -net 127.0.0.0来修复它,但通常操作系统会自动设置它,所以您的系统中可能还有其他问题...... -
我尝试使用 ifconfig 但必须使用
sudo apt install net-tools才能使用 ifconfig。安装失败。我得到的错误:E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60+git20180626.aebd88e-1ubuntu1_am--- 所以我不能使用 ifconfig
标签: ubuntu redis windows-subsystem-for-linux