title: How to fix 502 Bad Gateway Error in production(Nginx)?
body: <p>When I tried to upload a big csv file of size about 600MB in my project which is hosted in the digital ocean, it tries to upload but shows 502 Bad Gateway Error (Nginx).</p>
  <p>The application is a data conversion application.</p>
  <p>This works fine while working locally.</p>
  <pre><code>sudo tail -30 /var/log/nginx/error.log
  </code></pre>
  <p>shows</p>
  <pre><code>[error] 132235#132235: *239 upstream prematurely closed connection while reading response header from upstream, client: client's ip , server: ip, request: &quot;POST /submit/ HTTP/1.1&quot;, upstream: &quot;http://unix:/run/gunicorn.sock:/submit/&quot;, host: &quot;ip&quot;, referrer: &quot;http://ip/&quot;
  
  sudo nano /etc/nginx/sites-available/myproject
  </code></pre>
  <p>shows</p>
  <pre><code>server {
      listen 80;
      server_name ip;
      client_max_body_size 999M;
  
      location = /favicon.ico { access_log off; log_not_found off; }
      location /static/ {
         alias  /root/static/;
      }
      location / {
          include proxy_params;
          proxy_pass http://unix:/run/gunicorn.sock;
      }
  }
  </code></pre>
  <p>nginx.conf</p>
  <pre><code>user root;
  worker_processes auto;
  pid /run/nginx.pid;
  include /etc/nginx/modules-enabled/*.conf;
  
  events {
          worker_connections 768;
          # multi_accept on;
  }
  
  http {
  
          ##
          # Basic Settings
          ##
  
          sendfile on;
          tcp_nopush on;
          tcp_nodelay on;
          keepalive_timeout 65;
          types_hash_max_size 2048;
          # server_tokens off;
  
          # server_names_hash_bucket_size 64;
          # server_name_in_redirect off;
  
          include /etc/nginx/mime.types;
          default_type application/octet-stream;
  </code></pre>
  <p>I have also the javascript loader running while the conversion process takes place.
  How can I fix this?</p>