Connect to node js server running on vagrant machine
<p>I have a simple <code>node http server</code> running on a <code>vagrant</code> VM. I would like to address to it with my browser on my local machine.</p>

<pre><code>varhttp=require("http");

http.createServer(function(request,response){
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World");
    response.end();
}).listen(3000);
</code></pre>

<p>This is my Vagrantfile:</p>

<pre><code>VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "ubuntu/xenial64"
    config.vm.network "forwarded_port", guest: 80, host: 8080
    config.vm.provision "shell", path: "config.sh"
end
</code></pre>

<p>I can't figure out how to address it from my browser.</p>

<p>Whenever I do <code>curl localhost:3000</code> in the vagrant VM, I get the <code>Hello world</code> message.</p>

<p>From my local machine I get <code>This site can’t be reached</code> whenever I try to open <code>localhost:8080</code>, as suggested in <a href="https://www.vagrantup.com/docs/networking/forwarded_ports.html" rel="nofollow noreferrer">Vagrant forwarding</a>.</p>