Vagrant 上的 nodejs - 无法从外部加载页面 [英] nodejs on Vagrant - can't load the page from outside
问题描述
尝试在浏览器中加载 http://localhost:3000 在我的 Windows 机器上不起作用,但是当我这样做
Trying to load http://localhost:3000 in browser doesn't work from my windows machine, but when I do this
curl -v http://localhost:3000
在我的流浪虚拟机上 - 页面加载正常.
on my vagrant VM - page loads fine.
我在考虑端口转发问题,所以我设置了
I was thinking about port forwarding issue, so I set
config.vm.network :forwarded_port, guest: 3000, host: 3000
在 vagrant 配置文件中,但没有帮助.
in vagrant config file, but it doesn't help.
我尝试在我的虚拟机上捕获对端口 3000 的调用,就像这样
I've tried to capture calls to port 3000 on my vm, like this
sudo tcpdump -i eth0 'port 3000'
这表明 vagrant VM 可以听到我对它的调用,但 nodemon 不知道.
This indicates that vagrant VM can hear my calls to it, but nodemon doesn't know about it.
我被困在这里,任何建议表示赞赏.
I'm stuck here, any advice appreciated.
谢谢!
推荐答案
谢谢m1keil!
我做了 sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
并解决了问题
I did sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
and it solved the problem
这篇关于Vagrant 上的 nodejs - 无法从外部加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!