title: Getting "EHOSTUNREACH" when trying to connect to API using Axios + Express.js
body: <p>I started playing around with the Philips Hue Bridge API by sending it requests using Postman.  I was able to authenticate myself, create a user and even successfully turn lights on or off.
  Conclusion: I am able to reach the API.</p>
  <p>Next I made a mini test javascript file to do the exact same using Node.js and <code>axios@0.21.4</code>. When I try the following code everything works and I receive the expected JSON responses:</p>
  <pre><code>const axios = require('axios')
  
  axios({
      method: 'GET',
      url: 'http://philips-hue.local/api/BYLCIlxABzz2eDHAxx70T'
  })
      .then(({data}) =&gt; {
          console.log('------&gt; AXIOS RES: ', data)
      })
      .catch((err) =&gt; {
          console.log('------&gt; AXIOS ERR: ', err)
      })
  </code></pre>
  <p>Conclusion: Axios is able to communicate with the API.</p>
  <p>Next I wanted to build this into an Express.js endpoint.  However when I try to use the same code inside of <code>express@4.17.1</code> I get an error:</p>
  <pre><code>router.route('/getlights').get((req, res) =&gt; {
      axios({
          method: 'GET',
          url: 'http://philips-hue.local/api/BYLCIlxABzz2eDHAxx70T/lights'
          })
          .then(({data}) =&gt; {
              console.log('------&gt; AXIOS RES: ', data)
              res.json({
                  state: 'SUCCESS',
                  data
              })
          })
          .catch((err) =&gt; {
              console.log('------&gt; AXIOS ERR: ', err)
              res.json({
                  state: 'ERROR',
                  err
              })
          })
  })
  </code></pre>
  <p>Response:</p>
  <pre><code>{
      &quot;state&quot;: &quot;ERROR&quot;,
      &quot;err&quot;: {
          &quot;message&quot;: &quot;connect EHOSTUNREACH 192.168.0.107:80&quot;,
          &quot;name&quot;: &quot;Error&quot;,
          &quot;stack&quot;: &quot;Error: connect EHOSTUNREACH 192.168.0.107:80\n    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)&quot;,
          &quot;config&quot;: {
              &quot;url&quot;: &quot;http://philips-hue.local/api/BYLCIlxABzz2eDHAxx70T/lights&quot;,
              &quot;method&quot;: &quot;get&quot;,
              &quot;headers&quot;: {
                  &quot;Accept&quot;: &quot;application/json, text/plain, */*&quot;,
                  &quot;User-Agent&quot;: &quot;axios/0.21.1&quot;
              },
              &quot;transformRequest&quot;: [
                  null
              ],
              &quot;transformResponse&quot;: [
                  null
              ],
              &quot;timeout&quot;: 0,
              &quot;xsrfCookieName&quot;: &quot;XSRF-TOKEN&quot;,
              &quot;xsrfHeaderName&quot;: &quot;X-XSRF-TOKEN&quot;,
              &quot;maxContentLength&quot;: -1,
              &quot;maxBodyLength&quot;: -1
          },
          &quot;code&quot;: &quot;EHOSTUNREACH&quot;
      }
  }
  </code></pre>
  <p>I started troubleshooting the problem by first trying to changing the URL to a random online place holder like <code>http://jsonplaceholder.typicode.com/posts/1</code> just to see if I could establish any connection at all.  This actually worked right away.</p>
  <p>This is where I got really confused.  Why am I able to successfully communicate with the bridge using Postman or Axios in a javascript file, but NOT able to connect with it when the same Axios code is used by express.  The problems seems to occur only when using both axios and express to connect to the bridge API.</p>
  <p>I have already tried retesting this with <code>node-fetch</code> and 3 other versions of Axios.  All tests failed the exact same way.  The code by itself can always connect to the API but once the code is being called by express it causes the EHOSTUNREACH error.</p>
  <p>I ran out of ideas on how to further google this issue since I am not sure what exactly is causing the problem (express and/or axios and/or bridge).  Any trouble shooting ideas or google keywords are also very welcome. :)</p>