title: Apache reverse proxy to Kestrel not working
body: <p>In a Ubuntu 18.04 server I have Apache (currently running several PHP sites whit no problem).
  Now I need to host a .NET app (v 3.1).</p>
  
  <p>Followed this tutorial <a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1</a></p>
  
  <p>The app is working if I'm not wrong</p>
  
  <pre><code># sudo systemctl status kestrel-helloapp.service
  ● kestrel-helloapp.service - Example .NET Web API App
     Loaded: loaded (/etc/systemd/system/kestrel-helloapp.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2020-03-10 15:27:21 UTC; 1h 33min ago
   Main PID: 70301 (dotnet)
      Tasks: 15 (limit: 4675)
     CGroup: /system.slice/kestrel-helloapp.service
             └─70301 /usr/bin/dotnet /var/www/helloapp/NetTest.dll
  
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]:       Now listening on: http://localhost:5000
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]:       Now listening on: https://localhost:5001
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]:       Application started. Press Ctrl+C to shut down.
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]:       Hosting environment: Production
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
  Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]:       Content root path: /var/www/helloapp
  </code></pre>
  
  <p>My Apache virtualhost is defined this way:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ProxyPreserveHost On
  
      ProxyPass / http://localhost:5000/
      ProxyPassReverse / http://localhost:5000/
      ServerAdmin webmaster@localhost
      ServerName XXXX-api.AAAA.com.ar
      ServerAlias www.XXXX-api.AAAA.com.ar
      ErrorLog ${APACHE_LOG_DIR}/XXXX-api.error.log
      CustomLog ${APACHE_LOG_DIR}/XXXX-api.access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>The .service content is:</p>
  
  <pre><code>[Unit]
  Description=Example .NET Web API App
  
  [Service]
  WorkingDirectory=/var/www/helloapp
  ExecStart=/usr/bin/dotnet /var/www/helloapp/NetTest.dll
  Restart=always
  # Restart service after 10 seconds if the dotnet service crashes:
  RestartSec=10
  KillSignal=SIGINT
  SyslogIdentifier=dotnet-example
  User=afiori
  Environment=ASPNETCORE_ENVIRONMENT=Production
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>When I go to XXXX-api.AAAA.com.ar it redirects me to XXXX-api.AAAA.com.ar:5001 and shows a ERR_CONNECTION_TIMED_OUT error</p>
  
  <p>Error log shows this:</p>
  
  <pre><code>[Tue Mar 10 15:06:49.538374 2020] [proxy_http:error] [pid 47754] [client 152.171.888.888:60836] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
  [Tue Mar 10 15:08:38.802652 2020] [proxy:error] [pid 9643] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:5000 (127.0.0.1) failed
  [Tue Mar 10 15:08:38.802698 2020] [proxy_http:error] [pid 9643] [client 152.171.888.888:60899] AH01114: HTTP: failed to make connection to backend: 127.0.0.1, referer: http://XXXX-api.AAAA.com.ar
  </code></pre>
  
  <p>I'm a bit lost here (I'm not even a .NET dev, my skills are in PHP)</p>