I am receiving an error saying "CurlException: Couldn't connect to server"
I am trying to access an API with this code in the client controller:
var tokenClient = new TokenClient("http://localhost:5003/connect/token", "client", "secret");
var tokenResponse = await tokenClient.RequestClientCredentialsAsync("api1");
var client = new HttpClient();
client.SetBearerToken(tokenResponse.AccessToken);
var content = await client.GetStringAsync("http://localhost:5102/api/catalog/items");
ViewBag.Json = JArray.Parse(content).ToString();
return View("json");
This is the code in the client:
services.AddAuthentication(options =>
        {
            options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            // options.DefaultAuthenticateScheme = "Cookies";
        })
        .AddCookie()
        .AddOpenIdConnect(options => {
            options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.Authority = identityUrl.ToString();
            options.SignedOutRedirectUri = callBackUrl.ToString();
            options.ClientId ="client";
            options.ClientSecret = "secret";
            options.ResponseType =  "code id_token";
            options.SaveTokens = true;
            options.GetClaimsFromUserInfoEndpoint = true;
            options.RequireHttpsMetadata = false;
            options.Scope.Add("openid");
            options.Scope.Add("profile");
            options.Scope.Add("api1");
The code in the IdentityServer config:
new Client
            {
                ClientId = "client",
                ClientSecrets = new [] { new Secret("secret".Sha256())},
                AllowedGrantTypes = GrantTypes.Hybrid,
                RedirectUris = { "http://localhost:5202/signin-oidc" },
                PostLogoutRedirectUris = {"http://localhost:5202/signout-callback-oidc"},
                AllowAccessTokensViaBrowser = false,
                AllowOfflineAccess = true,
                RequireConsent = true,
                AlwaysSendClientClaims = true,
                AlwaysIncludeUserClaimsInIdToken = true,
                AllowedScopes = new List<string>
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    //"MobileApi"
                    "api1"
                }
And the code in the Api:
        services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority =Configuration.GetValue<string>("IdentityUrl");
                options.RequireHttpsMetadata = false;
                options.ApiName = "api1";
            });
All Url variables are correct, I've used them in other places without issue. I believe the issue is with docker because of this thread on github: https://github.com/aspnet/Home/issues/1975. However the "answer" has no explantion and is vague in its execution. Is there a way to fix this issue so that I that client can connect to the api through docker?
 
    