admin管理员组文章数量:1401954
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 ining 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
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 ining 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
- 1 have you tried 127.0.0.1:8888? – eis Commented Jun 7, 2012 at 16:49
- Works for me. Did you perhaps enter a wrong URL? – Florian Salihovic Commented Jun 7, 2012 at 16:49
-
1
are you running a software firewall? Does this url work in your browser:
http://127.0.0.1
? – agent-j Commented Jun 7, 2012 at 16:50 - another thing that occurred to my mind - if your browser is using a proxy that doesn't have an exception rule for local addresses, it may be trying to access it with a proxy. You could try to telnet to that port. – eis Commented Jun 7, 2012 at 16:50
- how can you say it works for you? – Esailija Commented Jun 7, 2012 at 16:51
1 Answer
Reset to default 2This code works--I just tried it and navigated to localhost:8888 and saw the expected output.
It's possible that you have a firewall that's too restrictive or you have a bad install of Node.js.
本文标签: javascriptnodejs server not runningStack Overflow
版权声明:本文标题:javascript - node.js server not running - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744298663a2599470.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论