Any one tried of Django Postgres with Ngnix?

50 views
Skip to first unread message

khaleela...@gmail.com

unread,
Jul 14, 2016, 10:16:40 AM7/14/16
to Django users

 Any one tried of Django Postgres with Ngnix?

Rafael E. Ferrero

unread,
Jul 14, 2016, 10:43:53 AM7/14/16
to django...@googlegroups.com
YES, I do !!


Rafael E. Ferrero

2016-07-14 11:16 GMT-03:00 <khaleela...@gmail.com>:

 Any one tried of Django Postgres with Ngnix?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e3f5d76a-a844-44a0-847c-eb0e18c3c3da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vijay Khemlani

unread,
Jul 14, 2016, 11:09:00 AM7/14/16
to django...@googlegroups.com
nginx + uwsgi + postgres here

khaleela...@gmail.com

unread,
Jul 15, 2016, 12:51:22 AM7/15/16
to Django users
Hello all,thanks for the response.

I do use ngnix + uwsgi + postgres.

Before it was mongo DB, am migrating that to postgres. When I change the settings from mongo to postgres in Django settings file, immediately I get 502 bad gateway error.

And in ngnix log following error occurs:
 " upstream prematurely closed connection while reading response header from upstream"

When I revert that settings back to mongo - it works fine.

Did any one of you encountered this type of issues during your deployment ?

06us...@gmail.com

unread,
Jul 15, 2016, 2:43:39 AM7/15/16
to Django users
Hello, I do use nginx + uwsgi + postgres. Maybe you could try one of following points below ?
Cheers.

1) there is a very good tutorial to install nginx, see below. This is the one I used for step by step installation on production server :
http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

2) on top of my head, I had error " upstream prematurely closed connection while reading response header from upstream" one or two times several months ago, while installing production server. This was due to an incorrect setting in nginx configuration file 'mysite_nginx.conf'. I do not remember exactly which setting, sorry (are you running http or https ?).

3) you could check that your postgresql server is up and running (I do this with webmin http://www.webmin.com/ ).

4) you could try to install first nginx using 'TCP port socket' (and not 'Unix socket') for test purpose. This is explained in tutorial above.

5) you could look at nginx error log in /var/log/nginx directory

6) error could be due to incorrect permissions. So maybe you should set permissions as below (this is explained in tutorial) :
uwsgi --socket site.sock --wsgi-file test.py --chmod-socket=666


7) you could add settting below in django settings.py in order to receive description of error by mail

ADMINS = (

('ME', ‘jd...@gmail.com'),

)



Reply all
Reply to author
Forward
0 new messages