title: connection refused error with Krakend api-gateway?
body: <p>I want to see and try how does <code>api-gateway</code> work specifically I am using <code>Krakend</code>. For technically, I have a service where it only receives a request and respond back. The problem is the service which is a very simple http-server does not receive the request from the <code>api-gateway</code> when the regarding endpoint is triggered through <code>api-gateway</code>. However, when I make a get request through browser writing the exact url <code>http://localhost:8000/api/v1/users</code>, I get the response. Basically, what I want is, when I make a get request to the <code>localhost:8099/users</code> which is the <code>api-gateway</code> I want api-gateway to make a get request to the <strong>users api</strong> and see the expected logs.</p>
  <p>This is the error I get.</p>
  <blockquote>
  <p>Error #01: Get &quot;http://localhost:8000/api/v1/users&quot;: dial tcp 127.0.0.1:8000: connect: connection refused</p>
  </blockquote>
  <p>Here is my <code>krakend.json</code> file where I put the configuration.</p>
  <pre><code>{
      &quot;version&quot;: 2,
      &quot;host&quot; : [
          &quot;http://localhost:8099&quot;
      ],
      &quot;extra_config&quot;: {
        &quot;github_com/devopsfaith/krakend-cors&quot;: {
          &quot;allow_origins&quot;: [
            &quot;*&quot;
          ],
          &quot;expose_headers&quot;: [
            &quot;Content-Length&quot;
          ],
          &quot;max_age&quot;: &quot;12h&quot;,
          &quot;allow_methods&quot;: [
            &quot;GET&quot;
          ],
          &quot;allow_headers&quot;: [
            &quot;*&quot;
          ]
        }
      },
      &quot;timeout&quot;: &quot;3000ms&quot;,
      &quot;cache_ttl&quot;: &quot;300s&quot;,
      &quot;output_encoding&quot;: &quot;string&quot;,
      &quot;name&quot;: &quot;api-gateway&quot;,
      &quot;port&quot;: 8099,
      &quot;read_timeout&quot;: &quot;5s&quot;,
      &quot;idle_timeout&quot;: &quot;5s&quot;,
      &quot;write_timeout&quot;: &quot;5s&quot;,
      &quot;read_header_timeout&quot;: &quot;5s&quot;,
      &quot;endpoints&quot;: [
        {
          &quot;endpoint&quot;: &quot;/users&quot;,
          &quot;method&quot; : &quot;GET&quot;,
          &quot;backend&quot;: [
            {
              &quot;encoding&quot; : &quot;string&quot;,
              &quot;url_pattern&quot;: &quot;/api/v1/users&quot;,
              &quot;method&quot;: &quot;GET&quot;,
              &quot;host&quot;: [
                &quot;http://localhost:8000&quot;
              ]
            }
          ]
        }
      ]
    }
  </code></pre>
  <p>And this is my node js server.</p>
  <pre><code>const express = require('express')
  const app = express()
  const cors = require('cors')
  
  var corsOptions = {
      origin: 'http://localhost:8099',
      methods: &quot;GET, PUT&quot;
  }
  
  app.use(cors(corsOptions))
  
  app.get('/api/v1/users', (req, res) =&gt; {
      console.log('REQUEST =&gt; \n')
      console.log(req.url)
      console.log(req.hostname)
  })
  
  app.listen(8000, () =&gt; {console.log('server has started on 8000')})
  
  </code></pre>
  <p>So, when I make a get request to the address <code>http://localhost:8099/users</code> the log is as follows:</p>
  <pre><code>[GIN] 2021/06/30 - 22:44:05 | 500 |      4.8998ms |      172.17.0.1 | GET      &quot;/users&quot;
  Error #01: Get &quot;http://localhost:8000/api/v1/users&quot;: dial tcp 127.0.0.1:8000: connect: connection refused
  </code></pre>
  <p>In the <code>Krakend</code> documentation here it says when status codes above 400 are returned from the backend, &quot;I guess&quot; the log is written as above with <code>500</code> code.</p>
  <blockquote>
  <p>500 Internal Server Error Default error code, and in general, when backends return any status above 400</p>
  </blockquote>
  <p>I did play with the <code>krakend.json</code> file and changed different parts of the file and still didn't work.</p>
  <p>I know this is a <code>tcp</code> error checked what could be the reasons causing that error.
  1- port may be crashed, which is not true because  when I make a get request directly to the endpoint <code>http://localhost:8000/api/v1/users</code> I get the log.</p>