ASP.NET Core with Docker ConnectionRefused on First Load

I am working on an ASP.NET Core app with a docker-based microservices architecture. When I start debugging my app using IIS Express I keep getting a Socket Error on the first load. After refreshing the page everything works fine. My instincts tell me that the issue is that I am trying to make an http request to a service before the docker container is started, but i have depends_on clauses in my docker_compose file. Any help would be much appreciated.

This is the part that is throwing an error (called in Home.Index Action):

HttpResponseMessage response = await _httpClient.GetAsync(_appSettings.Value.ListingsAPIUrl + "/Listings");

Here is my docker-compose:

services:
  sql.data:
    image: microsoft/mssql-server-linux:2017-latest

  listings.api:
    image: ${REGISTRY:-listings}/listings.api:${TAG:-latest}
    build:
      context: .
      dockerfile: src/Services/Listings/Listings.API/Dockerfile
    depends_on:
      - sql.data

  webmvc:
    image: ${DOCKER:-listings}/webmvc:${TAG:-latest}
    build:
      context: .
      dockerfile: src/WebApps/WebMVC/Dockerfile
    depends_on:
      - listings.api

Here is my Program.cs:

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
}

here are the relevant parts of my Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddCustomMVC(Configuration)
            .AddAppSettings(Configuration)
            .AddCustomHttpClients(Configuration);
            //.AddCustomAuthentication(Configuration, Environment);
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseCookiePolicy();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }

Custom Startup Extensions:

    public static IServiceCollection AddCustomMVC(this IServiceCollection services, IConfiguration configuration)
    {
        services.Configure<CookiePolicyOptions>(options =>
        {
            // This lambda determines whether user consent for non-essential cookies is needed for a given request.
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.None;
        }); 

        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

        return services;
    }

    public static IServiceCollection AddAppSettings(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddOptions();
        services.Configure<AppSettings>(configuration);

        return services;
    }

    public static IServiceCollection AddCustomHttpClients(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddHttpClient();

        return services;
    }

Source: StackOverflow