由于“错误:对等方重置连接”,无法从主机获取或设置 Vagrant 来宾上的 Redis

zub*_*uba 5 server virtualbox networking vagrant redis

我试图将访客端口 6379 转发到主机 6379 和 16379,但没有成功。

我可以从来宾连接到 redis 并设置和获取,尽管我也可以从主机连接到 redis 并获得帮助,但我无法设置或获取.

我没有在来宾或主机上运行防火墙。任何帮助表示赞赏。

来自主机:

host: > redis-cli -h localhost -p 16379
localhost:16379> help
redis-cli 2.8.4
Type: "help @<group>" to get a list of commands in <group>
      "help <command>" for help on <command>
      "help <tab>" to get a list of possible help topics
      "quit" to exit
localhost:16379> help get

  GET key
  summary: Get the value of a key
  since: 1.0.0
  group: string

localhost:16379> get 'x'
Error: Connection reset by peer
localhost:16379> set 'x' 12
Error: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)

来自客人:

vagrant:~$ redis-cli -v
redis-cli 2.8.4
vagrant:~$ redis-cli
127.0.0.1:6379> set 'x' 12
OK
127.0.0.1:6379> get x
"12"
Run Code Online (Sandbox Code Playgroud)

zub*_*uba 6

解决方案在这里:检查您的/etc/redis/redis.conf,并确保更改默认值

bind 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

bind 0.0.0.0
Run Code Online (Sandbox Code Playgroud)

然后重启你的服务 service redis-server restart

然后,您现在可以检查 redis 是否正在侦听非本地接口