I've set up a Digital Ocean one-click app (django + nginx + gunicorn are installed and setup https://www.digitalocean.com/community/tutorials/how-to-use-the-django-one-click-install-image). Defaults worked for me, but after I tried to apply code changes via
service gunicorn restart I received a 502 error with the following nginx error log line:
connect() to unix:/home/django/gunicorn.socket failed (111: Connection refused) while connecting to upstream, client: 126.96.36.199, server: _, request: "GET / HTTP/1.1",upstream: "http://unix:/home/django/gunicorn.socket:/"..
I have looked into similar issues and found that often it's caused by a mistake in ALLOWED_HOSTS, everything is right there, but I also tried to replace
'www.address.com' with single
'*' and got a different error:
recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 188.8.131.52, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "184.108.40.206"
EDIT: ok, now it's easier, gunicorn error log is telling us that there is an import error with rest_framework, But it's installed and it's present in Installed app (and spelled right), I'v checked like thousand times so what's really wrong with all that?
File "/usr/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application django.setup() File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/usr/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/usr/lib/python2.7/dist-packages/gevent/builtins.py", line 93, in __import__ result = _import(*args, **kwargs) File "/home/django/django_project/blog/models.py", line 5, in <module> from rest_framework import serializers File "/usr/lib/python2.7/dist-packages/gevent/builtins.py", line 93, in __import__ result = _import(*args, **kwargs) ImportError: No module named rest_framework
(the only issue for now)EDIT2: I have reinstalled the app folder, checked again everything. Now it's telling that
ImportError: No module named django_ajax. Python 2.7 , Django 1.8, Gunicorn 19.4.5 (https://github.com/yceruto/django-ajax) despite everything seems to be correct
EDIT: Résponse of pip freeze:
Django==1.8 django-filter==1.0.1 -e git://github.com/yceruto/django-ajax@9c122e68f8e7ca92333a1533fa464ee6da0f65c5#egg=djangoajax djangorestframework==3.5.3 gunicorn==19.6.0 Markdown==2.6.7 netifaces==0.10.5 pkg-resources==0.0.0 psycopg2==2.6.2