502 django + nginx + gunicorn error - connect () recv ()

I installed the one-click application in Digital Ocean (django + nginx + gunicorn) and installed https://www.digitalocean.com/community/tutorials/how-to-use-the-django-one-click-install-image ) . By default it worked for me, but after I tried to apply the code changes through service gunicorn restart, I got error 502 with the following line of the nginx error log:

 connect() to unix:/home/django/gunicorn.socket failed (111: Connection refused) while connecting to upstream, client: 178.136.215.70, server: _, request: "GET / HTTP/1.1",upstream: "http://unix:/home/django/gunicorn.socket:/"..

I have considered similar problems and found that often it is caused by an error in allowed_hosts, all right there, but I also tried to replace 'ip'or 'www.address.com'at one '*'and got another error:

recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 178.136.215.70, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "192.241.176.184"

EDIT: OK, now it's easier, the gun error log tells us that there is an import error with rest_framework, but it is installed and present in the Installed application (and it is spelled correctly), I'v checked like a thousand times, so it’s really wrong with all this ?

     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 problem at the moment) EDIT2: I reinstalled the application folder, checked everything again. Now he says that ImportError: No module named django_ajax. Python 2.7, Django 1.8, Gunicorn 19.4.5 ( https://github.com/yceruto/django-ajax ), despite the fact that everything seems to be correctenter image description here

EDIT: Failure to freeze a contour:

    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
+4
source share
2 answers

Sudo, root . , , sudo pip. , , .

, Python . dist-packages. . , Python, , .

, dist- /path/to/virtual _env/virtual_env/lib/python2.7/dist-packages, , . , .

,

DJANGODIR =///-/ DJANGO_SETTINGS_MODULE = django-project.settings

cd $DJANGODIR ///virtualenv/bin/ DJANGO_SETTINGS_MODULE = $DJANGO_SETTINGS_MODULE PYTHONPATH = $DJANGODIR: $PYTHONPATH

, ... , , -.

+2

, , , . - , . ,

  sudo -H pip install djangorestframework

, , . , pip freeze. , pip install , , , (?), , root, .

0

Source: https://habr.com/ru/post/1665637/


All Articles