I'd like to run Node.js server in virtual machine.
I executed vagrant up
and node Server.js
.
Then I accessed to http://192.168.33.10:1337/
from host machine browser.
But, the browser outputs ERR_EMPTY_RESPONSE
.
How do I fix it?
Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "centos"
config.vm.network "private_network", ip: "192.168.33.10"
end
Server.js
var http = require('http');
http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(1337, "192.168.33.10");
console.log('server running');
答案 0 :(得分:1)