gpt4 book ai didi

javascript - Node.js 始终给出 503 错误

转载 作者:行者123 更新时间:2023-11-28 05:54:17 24 4
gpt4 key购买 nike

我刚刚安装了 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/');

然后我启动了为 Node 设置的域 http://node.foobar.com - 当我上周在我的域上执行相同操作时,我成功地让它打印 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>

最佳答案

如何设置域?

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

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

也许您的 Node 崩溃了或者只是没有运行。

另一个测试是直接连接您的 Node :

http://127.0.0.1:8081/

关于javascript - Node.js 始终给出 503 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37832844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com