Empty reply from server - can't connect to vagrant vm w/port forwarding

前端 未结 3 1194
忘了有多久
忘了有多久 2020-12-13 14:10

I\'m running werkzeug (as part of a Tilestache setup) inside a Vagrant VM, running ubuntu \'precise.\'

In my Vagrantfile, I have:

config.vm.network :         


        
相关标签:
3条回答
  • 2020-12-13 14:19

    In the /etc/hosts inside the VM, change line
    127.0.0.1 localhost -> 0.0.0.0 localhost
    and then restart server

    0 讨论(0)
  • 2020-12-13 14:20

    This can also be a problem with your firewall on the vagrant machine. If you can curl the address while on the vagrant box, then check your firewalld settings or turn it off:

    on CENTOS:

    sudo service firewalld stop
    

    Then you should update your firewalld settings and restart it ;)

    0 讨论(0)
  • 2020-12-13 14:26

    When running a server from within a VM, start the server on 0.0.0.0 instead of 127.0.0.1.

    127.0.0.1 is only accessible to the local machine, which for a VM means nothing outside of the VM can reach it! 0.0.0.0 is accessible from anywhere on the local network, which to a VM includes the host machine.

    The answer came from here: Connection Reset when port forwarding with Vagrant

    (Which apparently got its answer from here: https://stackoverflow.com/a/5999945/738675)

    With help from: https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1

    Google-bait:

    Here are the errors you might receive if this is the problem:

    • Chrome: "No data received"
    • Firefox: "The connection was reset - The connection to the server was reset while the page was loading."
    • Safari: "Safari can’t open the page [URL] because the server unexpectedly dropped the connection"
    • curl: "Empty reply from server"
    0 讨论(0)
提交回复
热议问题