title: How should I resolve the following error message? (111)Connection refused: AH00957: HTTPS: attempt to connect to 127.0.0.1:5001 (127.0.0.1) failed
body: <p>As mentioned I am receiving the following error message in my apache logs.</p>
  <pre><code>[Sat Jun 22 12:57:53.746190 2019] [proxy:error] [pid 10299:tid 140435221571328] (111)Connection refused: AH00957: HTTPS: attempt to connect to 127.0.0.1:5001 (127.0.0.1) failed
  [Sat Jun 22 12:57:53.746228 2019] [proxy:error] [pid 10299:tid 140435221571328] AH00959: ap_proxy_connect_backend disabling worker for (127.0.0.1) for 60s
  [Sat Jun 22 12:57:53.746233 2019] [proxy_http:error] [pid 10299:tid 140435221571328] [client myip:65168] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
  </code></pre>
  <p>When deploying with code-pipline I see no error messages.</p>
  <p>I have tried all of the following;</p>
  <ul>
  <li>Restarting and rebuilding my application.</li>
  <li>Adjusting the launchSettings.json file in my ASP project.</li>
  <li>Adjusting the ports and enabling / disabling HTTPS redirect in my Program class.</li>
  <li>Adjusting my vhsosts file in apache.</li>
  </ul>
  <p>Here are some important files for you to browse;</p>
  <p>launchSettings.json</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;iisSettings&quot;: {
      &quot;windowsAuthentication&quot;: false,
      &quot;anonymousAuthentication&quot;: true,
      &quot;iisExpress&quot;: {
        &quot;applicationUrl&quot;: &quot;https://localhost:44335&quot;,
        &quot;sslPort&quot;: 44335
      }
    },
    &quot;profiles&quot;: {
      &quot;IIS Express&quot;: {
        &quot;commandName&quot;: &quot;IISExpress&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_My_Environment&quot;: &quot;1&quot;,
          &quot;ASPNETCORE_DETAILEDERRORS&quot;: &quot;1&quot;,
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;
        }
      },
      &quot;ProjectName&quot;: {
        &quot;commandName&quot;: &quot;Project&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;applicationUrl&quot;: &quot;https://localhost:5001;http://localhost:5000&quot;,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Production&quot;
        }
      }
    }
  }
  </code></pre>
  <p>/etc/apache2/sites-enabled/000-default.conf</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;VirtualHost *:80&gt;
      ProxyPreserveHost On
      ProxyPass &quot;/&quot; &quot;http://127.0.0.1:5000/&quot;
      ProxyPassReverse &quot;/&quot; &quot;http://127.0.0.1:5000/&quot;
  &lt;/VirtualHost&gt;
  </code></pre>
  <p>/etc/apache2/sites-enabled/000-default-le-ssl.conf</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;IfModule mod_ssl.c&gt;
  &lt;VirtualHost *:443&gt;
      SSLEngine on
      SSLProxyEngine on
  
      ProxyPreserveHost On
      ProxyPass &quot;/&quot; &quot;https://127.0.0.1:5001/&quot;
      ProxyPassReverse &quot;/&quot; &quot;https://127.0.0.1:5001/&quot;
      ServerName mydomain.com
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
  &lt;/VirtualHost&gt;
  &lt;/IfModule&gt;
  
  </code></pre>
  <p>Startup.cs</p>
  <pre class="lang-cs prettyprint-override"><code>        public void ConfigureServices(IServiceCollection services)
          {
              var logger = _loggerFactory.CreateLogger&lt;Startup&gt;();
  
  
              logger.LogInformation($&quot;Environment: {_env.EnvironmentName}&quot;);
  
              // Development service configuration
              if (_env.IsDevelopment())
              {
                  logger.LogInformation(&quot;Development environment&quot;);
  
                  services.Configure&lt;ForwardedHeadersOptions&gt;(options =&gt;
                  {
                      options.KnownProxies.Add(IPAddress.Parse(&quot;127.0.0.1&quot;));
                  });
  
                  services.AddHttpsRedirection(options =&gt;
                  {
                      options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect;
                      options.HttpsPort = 44335;
                  });
              }
  
              // Live Service Config
              if (!_env.IsDevelopment())
              {
                  services.AddHttpsRedirection(options =&gt;
                  {
                      options.RedirectStatusCode = StatusCodes.Status308PermanentRedirect;
                      options.HttpsPort = 5001;
                  });
  
                  services.Configure&lt;ForwardedHeadersOptions&gt;(options =&gt;
                  {
                      options.KnownProxies.Add(IPAddress.Parse(&quot;127.0.0.1&quot;));
                  });
  
                  services.AddHsts(options =&gt;
                  {
                      options.Preload = true;
                      options.IncludeSubDomains = true;
                      options.MaxAge = TimeSpan.FromDays(60);
                  });
  
              }
  
              //lines removed for berevity.
  }
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              // Dev Envoronments
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
                  app.UseHttpsRedirection();
              }
  
              if (env.IsProduction())
              {
                  app.UseExceptionHandler(&quot;/Home/Error&quot;);
                  app.UseHsts();
  
                  app.UseForwardedHeaders(new ForwardedHeadersOptions
                  {
                      ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
                  });
              }
  
  
              app.UseHttpsRedirection();
              //lines removed for berevity.
  }
  </code></pre>
  <p>If you need any more information please let me know.</p>
  <p>EDIT: Server: EC2 Ubuntu (Build via Code Star), Web service: Apache, Project Code: asp.net core 2.1, SSL Certificates: LetsEncrypt, Proxy: Not 100% sure.</p>