title: Ocelot API Gateway error: No connection could be made because the target machine actively refused it
body: <p>I am trying to build a microservice architecture system using Ocelot as my API Gateway.  I have had the current problem for about 2 weeks and have not been able to figure out why it is happening, so I am turing to the experts and hopefully you can help :).</p>
  <p>The structure at the moment is as follows: I have an AccountAPI and an Ocelot API Gateway.  I have added the route from the API Gateway to the AccountAPI according to the docs.  When I run the project, I can call the AccountAPI directly, and it works fine. But when I call through the API Gateway, I get this error.</p>
  <pre><code>Error Code: ConnectionToDownstreamServiceError Message: Error connecting to downstream service, exception: 
  System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. 
  (localhost:5101)
  </code></pre>
  <p>Quite obviously, it is not even reaching the controller of the AccountAPI, so I can't even debug &gt;.&gt;</p>
  <p>The fact that I can access the object without going through the gateway tells me it is not a network / firewall issue (I turned off all my firewalls just to test, and got the same result).</p>
  <p>This is what is in my ocelot.json file (which should connect Ocelot to the AccountAPI)</p>
  <pre><code>{
    &quot;GlobalConfiguration&quot;: {
      &quot;BaseUrl&quot;: &quot;http://localhost:5111/&quot;
    },
    &quot;Routes&quot;: [
      {
        &quot;DownstreamPathTemplate&quot;: &quot;/Account/{url}&quot;,
        &quot;DownstreamScheme&quot;: &quot;http&quot;,
        &quot;DownstreamHostAndPorts&quot;: [
          {
            &quot;Host&quot;: &quot;localhost&quot;,
            &quot;Port&quot;: 5101
          }
        ],
        &quot;UpstreamPathTemplate&quot;: &quot;/MeHealth/Account/{url}&quot;,
        &quot;UpstreamHttpMethod&quot;: [ &quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELETE&quot; ],
        &quot;Priority&quot;: 1
      }
    ]
  }
  </code></pre>
  <p>So if I call <code>https:// localhost:5101/Account/1</code>  I get my correct object returned.  But with calling <code>https:// localhost:5111/MeHalth/Account/1</code> I get the error. (I did also try <code>http://</code> (for those who caught the scheme) and I get the same result as https)).</p>
  <p>Other things to note:  Both of these are deployed through the docker-compose with the following config:</p>
  <pre><code>services:
      ocelotapigateway:
          environment:
              - ASPNETCORE_ENVIRONMENT=Development
              - ASPNETCORE_URLS=https://+:443;http://+:80
          ports:
              - &quot;5111:443&quot;
          volumes:
              - ${APPDATA}/Microsoft/UserSecrets:C:\Users\ContainerUser\AppData\Roaming\Microsoft\UserSecrets:ro
              - ${APPDATA}/ASP.NET/Https:C:\Users\ContainerUser\AppData\Roaming\ASP.NET\Https:ro
  
      accountapi:
          environment:
              - ASPNETCORE_ENVIRONMENT=Development
              - ASPNETCORE_URLS=https://+:443;http://+:80
          ports:
              - &quot;5101:443&quot;
          volumes:
              - ${APPDATA}/Microsoft/UserSecrets:C:\Users\ContainerUser\AppData\Roaming\Microsoft\UserSecrets:ro
              - ${APPDATA}/ASP.NET/Https:C:\Users\ContainerUser\AppData\Roaming\ASP.NET\Https:ro
  </code></pre>
  <p>Any advice or help that you can give will be greatly appreciated. Please also let me know if you need extra information on something.</p>