Macos Node.js HTTP服务器端口8080

Macos Node.js HTTP服务器端口8080,macos,node.js,port,Macos,Node.js,Port,我正在浏览一些node.js教程。我正在使用OSX10.6.8。第一个是以下内容 var http = require("http"); http.createServer(function (request, response) { request.on("end", function () { response.writeHead(200, { 'Content-Type': 'text/plain' }); response.en

我正在浏览一些node.js教程。我正在使用OSX10.6.8。第一个是以下内容

var http = require("http");
http.createServer(function (request, response) {
   request.on("end", function () {
      response.writeHead(200, {
         'Content-Type': 'text/plain'
      });
      response.end('Hello HTTP!');
   });
// Listen on the 8080 port.
}).listen(8080);
我似乎根本无法访问8080端口。当我访问我的localhost和127.0.0.1时,它们工作得很好,但是使用上面的例子127.0.0.1:8080/和localhost:8080/但是说“Safari无法连接到服务器”

我想这个端口很近怎么了?我相信这是一个常见的问题,但搜索并没有多大帮助

我还应该补充一点,防火墙在首选项中处于关闭状态


有什么想法吗?

我设法弄明白了。有趣的是,我在mac电脑上同时运行MAMP和常规OSXWeb服务。这很奇怪,因为我杀了MAMP,本地主机还在工作。我像什么?我杀了他们中的一个并仔细检查了港口。这为我释放了8080


谢谢

如果使用不同的端口会发生什么情况?
lsof-i:8080
然后
kill-9
生成的pid。