我尝试使用服务器端node.js并为http请求编写一个简单的通用javascript代码
var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.sendHeader(200, {"Content-Type": "text/html"});
response.write("Hello World!");
response.close();
}).listen(1337);
sys.puts("Server running 8080");
当我在服务器上执行时,它可以工作并给我输出“Server running 8080”字符串。
但是当我检查浏览器时无法连接到主机。 (我试试这个http://myserverip:1337) 我打开1337端口但还是一样
最佳答案
Linux 上也是同样的情况。检查您的网络连接。如果您在亚马逊上,请检查您的安全组。有东西阻塞了该端口。
关于linux - 服务器端node.js请求无法连接到主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28908797/