title: Run Django with Nginx Web SERVER 502 Bad Gateway
body: <p>How to fix issue 502 Bad Gateway nginx/1.18.0 (Ubuntu) for running Django?</p>
  <p>Nginx error log:</p>
  <pre><code>*29 upstream prematurely closed connection while reading response header from upstream, client:  x.x.x.x, s&gt;
  2022/03/18 15:33:51 [error] 890#890: *13 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x,&gt;
  2022/03/18 15:42:18 [error] 1976#1976: *2 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, &gt;
  2022/03/18 15:43:10 [error] 1976#1976: *2 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, &gt;
  2022/03/18 15:44:35 [error] 1976#1976: *7 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x&gt;
  </code></pre>