librelist archives

« back to archive

Error: 502 Bad Gateway while setuping up Flask app on Nignx

Error: 502 Bad Gateway while setuping up Flask app on Nignx

From:
Kundan Singh
Date:
2013-05-18 @ 16:17
I am trying to setup Flask app on Ubuntu, Nginx, uWSGI.

I tried following instructions from
http://tghw.com/blog/multiple-django-and-flask-sites-with-nginx-and-uwsgi-emperor

My app structure is:
* /*
*    var/*
*          /www*
*                   /flaskapp*
*                                 /flask : virtual env and installed Flask
in It*
*                                 app.py : containing basic Hello world
example*
*
*
also i used configuration setting as:

/etc/uwsgi/apps-available/flaskapp.ini

[uwsgi]
# Variables
base = /var/www/flaskapp
app = app
# Generic Config
plugins = http,python
home = %(base)/*flask #**instead of venv given in article*
pythonpath = %(base)
socket = /var/www/run/%n.sock
module = %(app)
logto = /var/log/uwsgi/%n.log



But when i start nginx it gives error:* 502 Bad Gateway*


What's the issue? Anything to do with my app structuring?

Please help.

Regards
Kundan Singh

Re: [flask] Error: 502 Bad Gateway while setuping up Flask app on Nignx

From:
Stefane Fermigier
Date:
2013-05-18 @ 16:29
I've just spent some time today setting up uWSGI myself for one of my 
websites ( https://github.com/abilian/lemooc-workshop-2013 if anyone's 
interested ) on an Ubuntu LTS server.

Here's my /etc/uwsgi/apps-enabled/lemooc2013.ini :

[uwsgi]
uid = fermigier
gid = fermigier
chdir = /home/fermigier/websites/lemooc2013
virtualenv = /home/fermigier/websites/envs/lemooc2013
socket = uwsgi.sock
chmod-socket = 666
pythonpath = .
wsgi-file = wsgi.py
callable = app
plugins = python
processes = 4
threads = 2

If you're running into troubles (as I did), you may want to check the 
uwsgi logs (in /var/log/uwsgi/app/ on my Ubuntu box).

Cheers,

  S.

On May 18, 2013, at 6:17 PM, Kundan Singh wrote:

> I am trying to setup Flask app on Ubuntu, Nginx, uWSGI.
> 
> I tried following instructions from 
http://tghw.com/blog/multiple-django-and-flask-sites-with-nginx-and-uwsgi-emperor
> 
> My app structure is:
>  /
>     var/
>           /www
>                    /flaskapp
>                                  /flask : virtual env and installed Flask in It
>                                  app.py : containing basic Hello world example
> 
> also i used configuration setting as:
> 
> /etc/uwsgi/apps-available/flaskapp.ini
> 
> [uwsgi]
> # Variables
> base = /var/www/flaskapp
> app = app
> # Generic Config
> plugins = http,python
> home = %(base)/flask #instead of venv given in article
> pythonpath = %(base)
> socket = /var/www/run/%n.sock
> module = %(app)
> logto = /var/log/uwsgi/%n.log
> 
> 
> But when i start nginx it gives error: 502 Bad Gateway
> 
> 
> What's the issue? Anything to do with my app structuring?
> 
> Please help.
> 
> Regards
> Kundan Singh

--
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier 
- http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/
Founder & board Member, Nuxeo - Open Source ECM - http://www.nuxeo.com/
Co-Founder and Chairman, Free&OSS Cluster - http://www.gt-logiciel-libre.org/
Co-Founder & Vice-President, National Council for Free&OSS - http://cnll.fr/

Re: [flask] Error: 502 Bad Gateway while setuping up Flask app on Nignx

From:
Kundan Singh
Date:
2013-05-19 @ 06:05
I tried checking my log file and it says:

Starting uWSGI 1.2.3-debian (32bit) on [Sun May 19 05:39:19 2013]
***compiled with version: 4.7.1 on 17 September 2012 17:20:40
detected number of CPU cores: 1
current working directory: /etc/uwsgi/apps-enabled
detected binary path: /usr/bin/uwsgi-core
your memory page size is 4096 bytes

detected max file descriptor number: 1024
lock engine: pthread robust mutexes
unlink(): Operation not permitted [socket.c line 75]
bind():
Address already in use [socket.c line 107]
removed uwsgi instance flaskapp.ini


Why this is happening and what is the solution?

Regards


On Sat, May 18, 2013 at 9:59 PM, Stefane Fermigier
<sfermigier@abilian.com>wrote:

> I've just spent some time today setting up uWSGI myself for one of my
> websites ( https://github.com/abilian/lemooc-workshop-2013 if anyone's
> interested ) on an Ubuntu LTS server.
>
> Here's my /etc/uwsgi/apps-enabled/lemooc2013.ini :
>
> [uwsgi]
> uid = fermigier
> gid = fermigier
> chdir = /home/fermigier/websites/lemooc2013
> virtualenv = /home/fermigier/websites/envs/lemooc2013
> socket = uwsgi.sock
> chmod-socket = 666
> pythonpath = .
> wsgi-file = wsgi.py
> callable = app
> plugins = python
> processes = 4
> threads = 2
>
> If you're running into troubles (as I did), you may want to check the
> uwsgi logs (in /var/log/ uwsgi/app/ on my Ubuntu box).
>
> Cheers,
>
>   S.
>
> On May 18, 2013, at 6:17 PM, Kundan Singh wrote:
>
> I am trying to setup Flask app on Ubuntu, Nginx, uWSGI.
>
> I tried following instructions from
> 
http://tghw.com/blog/multiple-django-and-flask-sites-with-nginx-and-uwsgi-emperor
>
> My app structure is:
> * /*
> *    var/*
> *          /www*
> *                   /flaskapp*
> *                                 /flask : virtual env and installed
> Flask in It*
> *                                 app.py : containing basic Hello world
> example*
> *
> *
> also i used configuration setting as:
>
> /etc/uwsgi/apps-available/flaskapp.ini
>
> [uwsgi]
> # Variables
> base = /var/www/flaskapp
> app = app
> # Generic Config
> plugins = http,python
> home = %(base)/*flask #**instead of venv given in article*
> pythonpath = %(base)
> socket = /var/www/run/%n.sock
> module = %(app)
> logto = /var/log/uwsgi/%n.log
>
>
>
> But when i start nginx it gives error:* 502 Bad Gateway*
>
>
> What's the issue? Anything to do with my app structuring?
>
> Please help.
>
> Regards
> Kundan Singh
>
>
> --
> Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier-
> http://linkedin.com/in/sfermigier
> Founder & CEO, Abilian - Enterprise Social Software -
> http://www.abilian.com/
> Founder & board Member, Nuxeo - Open Source ECM - http://www.nuxeo.com/
> Co-Founder and Chairman, Free&OSS Cluster -
> http://www.gt-logiciel-libre.org/
> Co-Founder & Vice-President, National Council for Free&OSS -
> http://cnll.fr/
>
>