getaddrinfo ENOENT error

Showing 1-2 of 2 messages
getaddrinfo ENOENT error Thuan le minh 5/24/12 1:24 AM
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 !
Re: getaddrinfo ENOENT error mscdex 5/24/12 2:05 AM
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'.