0

I did install all needed package and node.js to dedicated machine Windows 2008 Server.

 var http = require('http');
 var port = 1337;
 http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello World\n');
 }).listen(port, '127.0.0.1');
console.log('Server running at http://127.0.0.1:' + port );

So when I call http://local.host:1337/, I get 'Hello World' But if try to call this service from another machine: http://my.domain.ip.address:1337/ Ooops, I can't see nothing. I already switch Off firewall at all

Thanks, to All advices

1
  • You'd usually deploy node behind another server, the easiest to get this done if performance is not a huge issue is to put it behind IIS, if you get WebMatrix it comes with build in configuration files for that (I just don't know where else they're available online) if you create a Node project. Commented Sep 7, 2013 at 22:56

1 Answer 1

2

Listening to localhost or 127.0.0.1 only allows for responding to requests made from the same computer to that specific IP or hostname.

To have your application respond to requests for multiple IP addresses, you'll need to listen to each of them. You can either do this individually.

function server(req, res) {
    // ...
}

http.createServer(server).listen(port, '127.0.0.1');
http.createServer(server).listen(port, 'my.domain.ip.address');
http.createServer(server).listen(port, '<any other public facing IP address>');

Or, you can listen to IPADDR_ANY (0.0.0.0), which in a non-specific, meta address. And, this is the default value for the hostname argument, so you only need to specify the port.

http.createServer(function (req, res) {
    // ...
}).listen(port);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.