title: net::ERR_CONNECTION_CLOSED on remote server when there are more than 7 sub-documents in mongo document
body: <p>I am developing a MEAN project with angular 4.1.0.</p>
  
  <p>On my localhost, everything works without errors. When I deploy to the server however, retrieving a user with more than 8 question-answer pairs causes a <strong>net::ERR_CONNECTION_CLOSED</strong> error on the <strong>xhr</strong> request that angular's http module fires.</p>
  
  <p>The digital ocean droplet I am hosting on uses an nginx reverse proxy and uses a letsencrypt SSL certificate. 
  I have tried:</p>
  
  <ul>
  <li>Restarting server, nginx service, node.js etc.</li>
  <li>Increasing <code>client_max_body_size</code> to <code>20M</code> in the nginx config file</li>
  <li>Increasing <code>large_client_header_buffers</code>' size to <code>128k</code> in the nginx config file</li>
  </ul>
  
  <p>Other important facts:</p>
  
  <ul>
  <li>The <code>GET</code> request to <code>qapairs?jwt=ey..</code> never reaches the node.js app</li>
  <li>There is no mention of the request in <code>/var/log/nginx/error.log</code></li>
  <li><p>The failing requests shown in the <code>/var/log/nginx/access.log</code> are as follows:</p>
  
  <pre><code>89.15.159.19 - - [08/May/2017:14:25:53 +0000] "-" 400 0 "-" "-"
  89.15.159.19 - - [08/May/2017:14:25:53 +0000] "-" 400 0 "-" "-"
  </code></pre></li>
  </ul>
  
  <p>Please point me in possible directions.</p>
  
  <hr>
  
  <h1>The chrome dev tool network tab screenshots</h1>
  
  <ol>
  <li><p><strong>After logging in to an account where there are only 7 question answer pairs</strong>
  <img src="https://image.ibb.co/hxYV1Q/network_tab_quiz_remove_lte_7.png" alt="After logging in to an account where there are only 7 question answer pairs"></p></li>
  <li><p><strong>Then, after going to mlab.com and manually adding another question answer pair to same account and then refreshing the page (notice the number of questions in now 8)</strong>
  <img src="https://image.ibb.co/j0FcgQ/network_quiz_gt_7.png" alt="After going to mlab.com and manually adding another question answer pair to same account and then refreshing the page"></p></li>
  <li><p><strong>Finally, after logging in and out of the same account (notice the xhr request to <code>qapairs?jwt=ey...</code> returned a failed status)</strong>
  <img src="https://image.ibb.co/eNhevk/network_quiz_gt_8_fail.png" alt="After logging in and out of the same account"></p></li>
  </ol>
  
  <blockquote>
    <p><strong><em>/etc/nginx/sites-enabled/default</em></strong></p>
  
  <pre><code># HTTP — redirect all traffic to HTTPS
  server {
      listen 80;
      listen [::]:80 default_server ipv6only=on;
      return 301 https://$host$request_uri;
  }
  
  # etc
  
  # HTTPS  ^ ^  proxy all requests to the Node app
  server {
      # Enable HTTP/2
      listen 443 ssl http2;
      listen [::]:443 ssl http2;
      server_name subdomain.example.com;
  
      # Use the Let ^ ^ s Encrypt certificates
      ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
  
      # Include the SSL configuration from cipherli.st
      include snippets/ssl-params.conf;
  
      # Increase allowed URL length     
      large_client_header_buffers 4 128k;
  
      # Increase max body size
      client_max_body_size 20M;
  
      location / {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-NginX-Proxy true;
          proxy_pass http://subdomain.example.com:3001/;
          proxy_ssl_session_reuse off;
          proxy_set_header Host $http_host;
          proxy_cache_bypass $http_upgrade;
          proxy_redirect off;
      }
  }
  </code></pre>
  </blockquote>
  
  <hr>
  
  <blockquote>
    <p><strong><em>qa-pairs.service.ts</em></strong></p>
    
    <p><strong>The error is being caught here in the <code>getQAPairs</code> function. Being passed to the callback in the <code>catch</code> function a <code>ProgressEvent</code> object with a <code>type</code> property of
    <code>error</code>, <code>eventPhase</code> of <code>2</code>.</strong></p>
  
  <pre><code>@Injectable()
  export class QaPairsService {
    /* etc */
  
    getQAPairs () {
      const jwt = localStorage.getItem('jwt') ? `?jwt=${localStorage.getItem('jwt')}` : ''
  
      return this.http.get(this.qapairsUrl + jwt)
        .map(response =&gt; {
          this.qapairs = response.json().map((qapair: IQAPair) =&gt; new QAPair(qapair))
          this.qapairsChanged.emit(this.qapairs)
          return this.qapairs
        })
        .catch(
          (error: any) =&gt; {
            error = error.json()
            this.errorsService.handleError(error)
            return Observable.throw(error)
          }
        )
    }
  
    /* etc */
  }
  </code></pre>
  </blockquote>