ECONNREFUSED表示连接被拒绝,通常是由于目标主机或端口未开启或无法访问造成的。检查目标服务器是否处于运行状态并且端口是否打开,可以尝试使用其他工具测试连接目标服务器,如telnet或ping。如果检查发现服务器已经打开并且可访问,可以尝试增加Axios请求的超时时间。以下是一个示例,使用Axios库,将超时时间增加到5秒:
axios.get('http://example.com', {
timeout: 5000
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});