Skip to content

KUBE DNS Issue with Node JS there is error 1 Error: getaddrinfo EAI_AGAIN #68321

Closed
@leeadh

Description

Would like to ask how to resolve this issue. I am running a node JS app and one of my methods is as below:

app.post('/', function (req, res) {
  let city = req.body.city;
  let url = `http://api.openweathermap.org/data/2.5/weather?q=${city}&units=imperial&appid=${apiKey}`

  request(url, function (err, response, body) {
    if(err){
      res.render('index', {weather: null, error: 'Error, please try again'});
      console.log("there is error 1 "+ err);
    } else {
      let weather = JSON.parse(body)
      if(weather.main == undefined){
        res.render('index', {weather: null, error: 'Error, please try again'});
        console.log("there is error 2 "+ err);
      } else {
        let weatherText = `It's ${weather.main.temp} degrees in ${weather.name}!`;
        res.render('index', {weather: weatherText, error: null});
      }
    }
  });
})

Locally it is working fine. However, when I deploy to kubernetes, I get this error. there is error 1 Error: getaddrinfo EAI_AGAIN api.openweathermap.org api.openweathermap.org:80

So i assume its something to do with my kubedns issue and I did a bit of digging and I find that my dns has an endpoint. At this point, I am kinda unsure what to do next. I guess its something to do with my dns but I am unsure. ANy help?

C:\Users\adrlee\Desktop\oracle\wercker>kubectl get ep kube-dns --namespace=kube-system
NAME       ENDPOINTS                                               AGE
kube-dns   10.244.2.2:53,10.244.2.3:53,10.244.2.5:53 + 5 more...   20d

Metadata

Assignees

Labels

sig/networkCategorizes an issue or PR as relevant to SIG Network.triage/unresolvedIndicates an issue that can not or will not be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions