Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I run the following script

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

by doing:

node hello.js &

curl localhost

I get:

Hello World

But when I try to access this page from my PC (which is not the same computer as this server), it gives me a 'this webpage can not be found' error. This can't be a problem with the firewall because I can run nginx on port 80 just fine.

share|improve this question
    
Still running on 127.0.0.1? That IP is local to the machine and not the local network. –  Alister Bulman Feb 11 '11 at 0:30
    
whoops you are right :(. –  quilby Feb 11 '11 at 0:39

3 Answers 3

You told the server to listen on 127.0.0.1 and this is a internal ip of host 1

which is not reachable from outside: tell your server to listen to 0.0.0.0 and then it works

share|improve this answer

Change the 127.0.0.1 to your external IP. Thank you to alister bulman.

share|improve this answer
    
It's perfectly fine to mark your own answer as accepted, if it solves the problem. You won't get rep for it, but others will upvote if it works for them. –  sysadmin1138 Feb 11 '11 at 0:46
    
better - mark an answer as the solution! :-D –  Alister Bulman Feb 11 '11 at 0:51

Still running on 127.0.0.1? That IP is local to the machine and not the local network. You need a network IP address.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.