I'm desperately trying to figure out the issue of why I cannot deploy my flask application with uWSGI nginx and Ubuntu server.
Here is my error in nginx error log:
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"
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 504 Gateway Time-Out
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.
Here is my server block configuration file
server{
listen 80;
server_name itinareport.tk www.itinareport.tk;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/pinchrep2/itinarep/itinarep.sock;
}
Here is my service file:
[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
Here is my ini file
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = itinarep.sock
chmod-socket = 660
vacuum = true
die-on-term=true
Sometimes when deploying a flask app with library like Keras and others they have some issue with threading in uWSGI.
You can change a few things in myproject.ini to make it work:
master = false <-------- this
processes = 1 <--------- and this
cheaper = 0 to your myproject.inilazy-apps = true to your myproject.iniSo now your myproject.ini file may look like:
[uwsgi]
module = wsgi:app
master = false <-------- this
processes = 1 <--------- and this
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
cheaper = 0 <----------- also this, if option 1 is not enough or doesn't work
lazy-apps = true <------ in some case, this might help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With