getaddrinfo ENOENT error

1,453 views
Skip to first unread message

thuan le minh

unread,
May 24, 2012, 4:24:01 AM5/24/12
to nodejs
Hi all,
when i use http method to connect and get content data of any
webpages , there is an error appears : getaddrinfo ENOENT error


my code :

var qs = require('querystring');
var http = require('http');

var server = http.createServer(function(req, res){
res.writeHead(200, {'content-Type': 'text/plain'});

var options ={
host: 'www.nodejs.org',
port: 80,
path: '/' + '?' +qs.stringify({q: 'hello word'})
};
var req = http.get(options, function(response){
var res_data = ' ';
response.on('data', function(chunk){
res_data += chunk;
});
response.on('end', function(){
console.log(res_data);
});
res.end(res_data);
});
req.on('err', function(e){
console.log("Got error : " + e.message);
});
});
server.listen(7005);


**error:
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: getaddrinfo ENOENT
at errnoException (dns.js:31:11)
at Object.onanswer [as oncomplete] (dns.js:140:16)

some body help me to fix it !

thank a lot !

mscdex

unread,
May 24, 2012, 5:05:46 AM5/24/12
to nodejs
On May 24, 4:24 am, thuan le minh <leminhthua...@gmail.com> wrote:
> when i use http method to connect and get content data of any
> webpages , there is an error appears : getaddrinfo ENOENT error




Sounds like the machine you're using is having a problem trying to
resolve that particular address.




> my code :
>[...]
>      var res_data = ' ';
>      response.on('data', function(chunk){
>          res_data += chunk;
>      });
>      response.on('end', function(){
>          console.log(res_data);
>      });
>      res.end(res_data);

Unrelated, but I think you meant to put this last line inside the
response.on('end') callback ?

>   req.on('err', function(e){

Also, this should be 'error' not 'err'.
Reply all
Reply to author
Forward
0 new messages