Cannot reach Jekyll server on Vagrant from outside

☆樱花仙子☆ 提交于 2020-01-11 17:40:31

问题


I've built a Vagrant VM with hashicorp/precise32 box and installed Jekyll on it. I've set port 4000 forwarding on Vagrantfile:

config.vm.network :forwarded_port, host: 4000, guest: 4000

When I try jekyll server it seems everything works fine, but I cannot reach the server from outside.

Configuration file: /vagrant/test-site/_config.yml
Source: /vagrant/test-site
Destination: /vagrant/test-site/_site
Generating...
                done.
Auto-regeneration: enabled for '/vagrant/test-site'
Configuration file: /vagrant/test-site/_config.yml
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.

When I try to reach the server via curl, the output is:

curl: (56) Recv failure: Connection was aborted

I've tried with other servers on same port and I can reach them, so it not seems a forwarding problem.

Any idea?

Edited:

curl localhost:4000 works correctly inside VM. For some reason, the port forwarding is not working properly for Jekyll.


回答1:


The error was on Server address: http://127.0.0.1:4000/. It seems that localhost is the default host for Jekyll, so I need to run jekyll serve --host 0.0.0.0 for the server to be available from outside.

I find the answer here: Vagrant port forwarding not working. Cups not accesible from host



来源:https://stackoverflow.com/questions/27617217/cannot-reach-jekyll-server-on-vagrant-from-outside

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!