title: Unable to reach service using DNS
body: <p>I am using the <a href="https://www.npmjs.com/package/request" rel="nofollow noreferrer">request</a> package from NPM to handle some internal communication between services. I have also set the DNS server to the correct one (using Hashicorp Consul as my SD and DNS).</p>
  
  <p>I can do a dig on my local machine (where the services are running) to the consul DNS server and I am able to get back the correct response (an IP and port number.</p>
  
  <p>How I setup DNS in my app.js file6</p>
  
  <pre><code>dns.setServers([ `${config.consul.host}:8600` ]);
  </code></pre>
  
  <p>Set in a different file than app.js</p>
  
  <pre><code>options = {
      baseUrl: `http://auth.service.consul`,
      json: { '': '' },
      headers: { authorization: '' }
  };
  </code></pre>
  
  <p>Same file as options above</p>
  
  <pre><code>request.post(req.path, options, (error, response, body) =&gt; {
      console.log(error);
      if (error) throw error;
      res.status(response.statusCode).json(body);
  });
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
    errno: 'ENOTFOUND',
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'auth.service.consul',
    host: 'auth.service.consul',
    port: 80 }
  </code></pre>
  
  <p>I am wanting to be able to make requests to the 'auth' service when using Consul as my DNS server. I currently have a very hacky way of doing this but really would like to use DNS.</p>
  
  <p>I did find this but it is pertaining to the axios package not the request one I am trying to use even though it produces the same error the solution there didn't help.
  <a href="https://stackoverflow.com/questions/47591751/consul-service-discovery-with-dns-on-nodejs">Consul service discovery with DNS on Nodejs</a></p>