在本地网络服务器中运行node.js的问题

时间:2015-03-16 18:53:56

标签: node.js network-programming

我创建了一个简单的node.js服务器示例,在我的Debian服务器上运行,在本地网络上运行。 当我在本地访问它时它可以工作,但是当我从其他机器使用它的IP时它不起作用。

enter image description here

无法找到网址“http://192.168.2.220:3003

我在这个服务器上有其他项目,包括端口80的Apache。 我的错误在哪里? 这项工作还需要做些什么吗?

以下是服务器示例:

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('IT VORKS!\n');
}).listen(3003, '127.0.0.1');

console.log('Server running at http://127.0.0.1:3003/');

1 个答案:

答案 0 :(得分:1)

尝试以下方法:

  1. 检查防火墙设置。
  2. 使用.listen(3003, '192.168.2.220');代替.listen(3003, '127.0.0.1');