我无法在无业游民的盒子外壳之外访问转发的端口。
我创建了一个带有以下转发端口的游民箱。
config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true
config.vm.network "forwarded_port", guest: 27017, host: 27017 #mongodb
config.vm.network "forwarded_port", guest: 5000, host: 5000 #python flask port
config.vm.network "forwarded_port", guest: 5050, host: 5050 # NODE Port
config.vm.network "private_network", ip: "192.168.33.10"
我已经安装了python服务器和nodejs服务器。如果我缩进我的游民箱并尝试:curl http://localhost:5050
,它将正确返回我的nodejs hello世界。如果我curl http://localhost:5000
正确地进入了我的python3 hello世界。
但是,我无法在流浪者环境之外访问我的本地主机(流浪者中的服务器仍处于活动状态)
我在做什么错?
我正在设置一台新计算机-所以可能我没有在本地计算机上安装一些必不可少的东西,但是我已经安装了vagrant等的依赖项。
Ping localhost或127.0.0.1可以运行,但只能在没有端口的情况下进行。我从游民机之外的主机收到以下错误:
$ ping localhost:80
ping: cannot resolve localhost:80: Unknown host
$ ping localhost:8080
ping: cannot resolve localhost:8080: Unknown host
$ curl 'http://localhost:80'
curl: (7) Failed to connect to localhost port 80: Connection refused
$ curl 'http://localhost:8080'
curl: (56) Recv failure: Connection reset by peer
$ curl 'http://localhost:5000'
curl: (56) Recv failure: Connection reset by peer
$ curl 'http://localhost:5050'
curl: (56) Recv failure: Connection reset by peer
$ curl 'http://127.0.0.1:80'
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
$ curl 'http://127.0.0.1:8080'
curl: (56) Recv failure: Connection reset by peer
$ curl 'http://127.0.0.1:5000'
curl: (56) Recv failure: Connection reset by peer
$ curl 'http://127.0.0.1:5050'
curl: (56) Recv failure: Connection reset by peer
&静态IP中的以下内容,每个属性都经过短暂的延迟...
$ curl 'http://192.168.33.10:80'
curl: (7) Failed to connect to 192.168.33.10 port 80: Connection refused
$ curl 'http://192.168.33.10:8080'
curl: (7) Failed to connect to 192.168.33.10 port 8080: Connection refused
$ curl 'http://192.168.33.10:5000'
curl: (7) Failed to connect to 192.168.33.10 port 5000: Connection refused
$ curl 'http://192.168.33.10:5050'
curl: (7) Failed to connect to 192.168.33.10 port 5050: Connection refused
我正在使用Mac OS Catalina。我的防火墙已禁用,并允许所有连接。
虚拟机中sudo netstat -ntlp
的输出。
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 469/rpcbind
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 510/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 865/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 790/postgres
tcp 0 0 192.168.33.10:5050 0.0.0.0:* LISTEN 2730/node
tcp 0 0 192.168.33.10:5000 0.0.0.0:* LISTEN 4070/python
tcp6 0 0 :::111 :::* LISTEN 469/rpcbind
tcp6 0 0 :::22 :::* LISTEN 865/sshd
tcp6 0 0 ::1:5432 :::* LISTEN 790/postgres
这似乎与这里的问题类似,但我的vagrantfile中有正确的行:Vagrant, nodejs and iptable port forwarding
我还仔细检查了大约10个问题中指出的所有内容,例如: vagrant port forwarding doesn't work: Connection reset by peer