我已经使用昨天使用的模块cheerio,request和longjohn编写了一些代码,但是今天它总是抛出“ ECONNREFUSED”错误。
我尝试使用使用请求的简单示例代码:
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
}
else{
console.log(error);
}
})
但是它仍然返回:
{[Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
我只是想知道这可能是什么原因,所以我可以使用Web浏览器连接到Internet。
谢谢
最佳答案
这可能是因为该进程由于防火墙或代理而无法访问Internet。
检查您的防火墙和代理设置,并确保该过程可以访问Internet。