title: unable to connect to restful api hosted in docker container
body: <p>I am facing an issue with my project i've built an api project and put it into a docker container.</p>
  
  <p>I can reach the container via the web just fine using local host inside a browser, but when trying to consume it through code via restsharp, httpclient i get connection refused.</p>
  
  <p>I tried local host, the direct 172 address assigned and even exposed a port pointed to 127.0.0.1 per other directions i've read.</p>
  
  <p>I am at a lost of next steps because i can not seem to get this to work in any way</p>
  
  <p>here is my simple code i set up:</p>
  
  <p>api call</p>
  
  <pre><code>[Route("Internal/Email")]
      public class EmailController : ControllerBase
      {
          [Route("Get")]
          [HttpGet]
          public ActionResult&lt;string&gt; Get()
          {
              return "email got";
          }
      }
  </code></pre>
  
  <p>consumer call:</p>
  
  <pre><code>public class TestController : Controller
      {
          private ServiceUrlConstants _serviceUrlConstants = new ServiceUrlConstants();
          private string _serviceUrl;
  public IActionResult GetEmail()
          {
              try
              {
                  _serviceUrl = _serviceUrlConstants.InternalServiceUrl;
                  var httpClient = new HttpClient();
                  var response = httpClient.GetAsync(_serviceUrl + "Internal/Email/Get");
                  var content = response.Result.Content.ReadAsStringAsync();
                  httpClient.Dispose();
                  //client = new RestClient(_serviceUrl + "Internal/Email/Get");
                  //var response = client.Execute(request);
                  //var content = response.Content;
                  return RedirectToAction("Index");
              }
              catch (Exception ex)
              {
                  return RedirectToAction("Index");
              }
          }
  }
  </code></pre>
  
  <p>Docker configuration (auto built by visual studio except third port exposure)</p>
  
  <pre><code>internalapiservice:
      environment:
        - ASPNETCORE_ENVIRONMENT=Development
        - ASPNETCORE_URLS=https://+:443;http://+:80
        - ASPNETCORE_HTTPS_PORT=44310
      ports:
        - "17399:80"
        - "44310:443"
        - "127.0.0.1:45310:45310"
      volumes:
        - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
        - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
  </code></pre>