Node.js一直给出503错误

时间:2016-06-15 10:29:35

标签: javascript node.js http-status-code-503

我刚刚安装了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.

这也发生在上周,在我关闭服务器,编辑代码,然后重新启动服务器之后,除非我等待几分钟才再次运行,否则它将会发生。但是,这次等待没有任何区别。

域名的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>

1 个答案:

答案 0 :(得分:0)

如何设置域名?

您是否使用其他HTTP服务器作为代理?

请检查节点是否正在运行,如果是,请检查您的HTTP服务器是否也正常。

可能您的节点崩溃或者没有运行。

另一项测试是直接连接您的节点:

http://127.0.0.1:8081/