Question

Django + nginx + gunicorn 502 bad gateway

Trying to set this all up, followed a tutorial, still doesn’t work.

gunicorn.conf

description "Gunicorn application server handling stocksearch"

start on runlevel [2345]
stop on runlevel [!2345]


setuid david
setgid www-data
chdir /home/david/stocksearch/stocksearch

exec /home/david/.virtualenvs/stocksearch/bin/gunicorn --workers 3 --bind unix:/home/david/stocksearch/stocksearch/stocksearch.sock stocksearch.wsgi:application

Nginx config:

server {
    listen 80;
    server_name 128.199.36.78;


    location /static/ {
        root /home/david/stocksearch/stocksearch;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/david/stocksearch/stocksearch/stocksearch.sock;
    }
}

Django:

# -*- coding: utf-8 -*-
from .base import *

DEBUG = False

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'stocksearch_db',
        'USER': 'david',
        'PASSWORD': 'david',
        'HOST': '',
        'PORT': '',
    }
}


STATIC_ROOT = os.path.dirname(BASE_DIR)
STATIC_URL = '/static/'

nginx logs:

2015/10/06 20:56:15 [error] 30688#0: *37 connect() to unix:/home/david/stocksearch/stocksearch/stocksearch.sock failed (111: Connection refused) while connecting to upstream, client: 79.176.114.181, server: 128.199.36.78, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/david/stocksearch/stocksearch/stocksearch.sock:/”, host: “128.199.36.78” 2015/10/06 20:56:15 [error] 30688#0: *37 connect() to unix:/home/david/stocksearch/stocksearch/stocksearch.sock failed (111: Connection refused) while connecting to upstream, client: 79.176.114.181, server: 128.199.36.78, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/david/stocksearch/stocksearch/stocksearch.sock:/”, host: “128.199.36.78”

gunicorn logs:

self.halt(reason=inst.reason, exit_status=inst.exit_status) File “/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/gunicorn/arbiter.py”, line 297, in halt self.stop() File “/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/gunicorn/arbiter.py”, line 342, in stop time.sleep(0.1) File “/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/gunicorn/arbiter.py”, line 214, in handle_chld self.reap_workers() File “/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/gunicorn/arbiter.py”, line 459, in reap_workers raise HaltServer(reason, self.WORKER_BOOT_ERROR) gunicorn.errors.HaltServer: <HaltServer ‘Worker failed to boot.’ 3>

Subscribe
Share

Hi,

Which tutorial were you following? Were you able to address this?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

same issue --any luck?