【发布时间】:2016-10-16 09:58:32
【问题描述】:
我刚刚安装了 Node.js,让它运行了一段时间,然后尝试运行一个标准的 Hello World 程序。
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8081);
// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');
然后我启动了我为节点设置的域http://node.foobar.com - 当我上周在我的域上做了同样的事情时,我成功地让它打印了Hello World。但是现在,我不断收到503 Service Temporarily Unavailable error.
上周也发生了这种情况,在我关闭服务器,编辑代码,然后重新运行服务器后,它会 503,除非我等待几分钟再运行。然而,这一次等待没有任何区别。
域的 Apache 配置:
<VirtualHost *:80>
ServerAdmin zadmin@localhost
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/node"
ServerName node.foobar.com
ProxyRequests on
ProxyPass / http://localhost:3102/
# Custom settings are loaded below this line (if any exist)
</VirtualHost>
【问题讨论】:
-
我知道这个问题之前已经解决了,不管是谁导致 503 的根本原因也是 NodeJS 代码本身。如果 Node.JS 代码中有错误,您的网页会很高兴地抛出 503 错误。 **这仅适用于使用相同代码遇到此问题但遇到不同问题的任何路人。
标签: javascript node.js http-status-code-503