我很难过。
我在子域上运行了一个节点js服务器。
每当我尝试从浏览器访问它时,我都会收到ERR_CONNECTION_REFUSED错误。
这是我的服务器代码
const http = require('http');
http.createServer( function (request, response){
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124, "my-server-ip");
console.log('Server running at http://127.0.0.1:8124/');
其他信息: 我正在使用Hostgator运行VPS。 子域与主域共享IP;像412.x.xx.xxx。
答案 0 :(得分:0)
在创建服务器功能中插入控制台日志。然后你可以识别错误。您也可以使用错误响应。
const http = require('http');
http.createServer( function (request, response){
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
console.log('Server running at http://127.0.0.1:8124/');
}).listen(8124, "my-server-ip");