I am working at my django
project with nginx
and gunicorn
, as it said here:
My site works locally, but when I start nginx
and gunicorn
server I had
502 Bad Gateway error.
OS is UBUNTU 14.04
I'm trying to make my project working, and reinstall everything as root (I know its bad) - the same mistake.
Here is my "error.log":
2016/04/20 20:15:10 [crit] 10119#0: *1 connect() to
unix:/root/myproject/myproject.sock failed (13: Permission denied) while connecting to upstream, client: 46.164.23
When i run comand "nginx
":
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
My gunicorn.conf
description "Gunicorn application server handling myproject"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid root
setgid www-data
chdir /root/myproject
exec myprojectenv/bin/gunicorn --workers 3 --bind unix:/root/myproject/myproject.sock myproject.wsgi:application
Thats my "/etc/nginx/sites-available/myproject"
server {
listen 80;
server_name www.mysite.ru;
error_log /nginx_error.log;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/root/myproject/myproject.sock;
}
}
I will appreciate your help very much!!!
The socket is in the superuser's home folder. That's pretty much inaccessible to all other users including your nginx users. Please more the socket to a different location. /var/log/gunicorn/ is a good place.
Also do i see you running gunicorn as root?. Not recommended.
Please use some other user here.
I think you have some other process using port 80, according to your nginx error log.
You'll have to figure out what that process is, and kill it if unneeded. Or use another port.