title: How do I diagnose a long Initial Connection to webpage hosted in AWS with Nginx/ELB/ECS
body: <p>I have a React web page that uses the Razzle framework for SSR, containerised and deployed into ECS along with an Nginx container. I use Route 53 for DNS, which routes the record to an ELB, then to the target group where my container resides.</p>
  <p>If I clear all browsing data and go to the site, it takes over a minute to establish an &quot;Initial Connection&quot; and everything else looks quick. Subsequent loads of the page do not take long at all.</p>
  <p><a href="https://i.stack.imgur.com/fBfeG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fBfeG.png" alt="Timing panel from Chrome Dev Tools" /></a></p>
  <p>I have no idea where to start to diagnose the issue, does anyone have an idea where I should look?</p>
  <p>Here is my Nginx configuration file</p>
  <pre><code>server {
    listen 80;
    listen [::]:80;
  
    if ($http_x_forwarded_proto = 'http'){
      return 301 https://$host$request_uri;
    }
  
    location / {
      proxy_pass http://0.0.0.0:3000;
      proxy_http_version 1.1;
      proxy_redirect     off;
      proxy_set_header   Upgrade $http_upgrade;
      proxy_set_header   Connection &quot;Upgrade&quot;;
      proxy_set_header   Host $host;
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header   X-Forwarded-Host $server_name;
    }
  }
  
  server {
    server_name www.&lt;domain&gt;.com;
    return 301 $scheme://&lt;domain&gt;.com$request_uri;
  }
  </code></pre>