title: Flask Nginx uWSGI 504 Gateway Timeout Error
body: <p>I'm desperately trying to figure out the issue of why I cannot deploy my flask application with uWSGI nginx and Ubuntu server.</p>
  
  <p>Here is my error in <strong>nginx error log</strong>:</p>
  
  <pre><code>2019/05/12 09:00:19 [error] 10154#10154: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 24.27.57.18, server: itinareport.tk, request: "POST /login HTTP/1.1", upstream: "uwsgi://unix:/home/pinchrep2/itinarep/itinarep.sock", host: "www.itinareport.tk", referrer: "http://www.itinareport.tk/login"
  </code></pre>
  
  <p>Upon having everything setup with flask uWSGI and nginx I'm able to put my domain name in and it takes me to my web page (Login Page). Upon attempting to login the page pauses for some time and then I receive the <strong>504 Gateway Time-Out</strong></p>
  
  <p>Please advise me on what I should do. This is my first time ever deploying an application and it's been taking me about a week of trying different configurations. I should have you know that I have my flask application connecting to a database through ssh tunnel to another server. Not sure if that would cause this issue as well. Please help if possible or point me in the right direction. </p>
  
  <p>Here is my <strong>server block configuration file</strong></p>
  
  <pre><code>server{
      listen 80;                                                                                                                           
      server_name itinareport.tk www.itinareport.tk;                                                                                       
  
      location / {                                                                                                                         
      include uwsgi_params;                                                                                                            
      uwsgi_pass unix:/home/pinchrep2/itinarep/itinarep.sock;                                                                          
  }                                                                                                                                    
  </code></pre>
  
  <p>Here is my <strong>service file</strong>:</p>
  
  <pre><code>[Unit]                                                                                                                                  
  Description=uWSGI instance to serve itinarep
  After=network.target
  
  [Service]
  User=pinchrep2
  Group=www-data
  WorkingDirectory=/home/pinchrep2/itinarep
  Environment="PATH=/home/pinchrep2/itinarep/it_venv/bin"
  ExecStart=/home/pinchrep2/itinarep/it_venv/bin/uwsgi --ini itinarep.ini
  
  [Install]
  WantedBy=multi-user.target  
  </code></pre>
  
  <p>Here is my <strong>ini file</strong>  </p>
  
  <pre><code>[uwsgi]
  module = wsgi:app
  
  master = true
  processes = 5
  
  socket = itinarep.sock
  chmod-socket = 660
  vacuum = true
  
  die-on-term=true 
  </code></pre>