Javascript Node.js始终给出503错误
我刚刚安装了Node.js,让它运行了一段时间,然后尝试运行一个标准的Hello World程序Javascript Node.js始终给出503错误,javascript,node.js,http-status-code-503,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
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/');
然后我启动了我为node设置的域,-上周我在我的域上做了同样的操作,成功地让它打印了Hello World
。但是现在,我不断收到503服务暂时不可用的错误。
这也发生在上周,在我关闭服务器,编辑代码,然后重新运行服务器之后,如果我在再次运行之前等待几分钟,它将运行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>
服务器管理员zadmin@localhost
DocumentRoot“/var/zpanel/hostdata/zadmin/public\u html/node”
ServerName node.foobar.com
代理请求
ProxyPass/http://localhost:3102/
#自定义设置加载在此行下方(如果存在)
如何设置域
您是否使用另一个HTTP服务器作为代理
请检查节点是否正在运行,如果是,请检查您的HTTP服务器是否也在运行
可能是您的节点崩溃或只是没有运行
另一个测试是直接连接节点:
http://127.0.0.1:8081/
如何设置域
您是否使用另一个HTTP服务器作为代理
请检查节点是否正在运行,如果是,请检查您的HTTP服务器是否也在运行
可能是您的节点崩溃或只是没有运行
另一个测试是直接连接节点:
http://127.0.0.1:8081/
我正在VPS Unix服务器上运行它,无法直接访问127.0.0.1:8081。域是使用Apache VirtualHost设置的,如编辑中所示。我做了ps aux | grep node
并看到node正在运行。实际上,您为我指明了正确的方向,谢谢!我的VHost设置使用的是端口3102
。因此问题在于Apache HTTP服务器试图通过错误的端口访问节点,结果导致503错误。对吗?我在VPS Unix服务器上运行它,无法直接访问127.0.0.1:8081。域是使用Apache VirtualHost设置的,如编辑中所示。我做了ps aux | grep node
并看到node正在运行。实际上,您为我指明了正确的方向,谢谢!我的VHost设置使用的是端口3102
。因此问题在于Apache HTTP服务器试图通过错误的端口访问节点,结果导致503错误。对吧?我知道这已经解决了,503s的一个根本原因也是NodeJS代码本身。如果Node.JS代码中有错误,您的网页将很乐意抛出503错误**这只适用于任何遇到相同代码问题但有不同问题的路人。我知道这已经解决了,503s的一个根本原因也是NodeJS代码本身。如果Node.JS代码中有错误,您的网页将很乐意抛出503错误**这仅适用于使用相同代码遇到此问题,但有不同问题的任何路人。