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.

I am trying to learn node.js, but I'm having trouble getting the simple server to run on localhost:8888.

Here is the code for server.js:

var http = require("http");

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

server.js runs without errors, and trying netstat -an | grep 8888 from terminal returns

tcp4       0      0  *.8888                 *.*                    LISTEN

However, when I go to localhost:8888 in a browser, it says that it cannot be found.

I've looked at all the related questions, and nothing has worked so far. I've tried different ports, etc. I know that my router blocks incoming traffic on port 8888, but shouldn't that not matter if I'm trying to access it locally? I've run tomcat servers on this port before, for example. Thanks so much for your help!

node.js version: v0.6.15
OS: Mac OS 10.6.8

share|improve this question
    
have you tried 127.0.0.1:8888 ? –  jfalcon Jun 8 '12 at 4:33

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.