user3779542
user3779542

Reputation: 29

django nginx uwsgi not working

i ve created a django application not using virtual environment. I ve installed nginx and trying to integrate them via uwsgi application. Here my configurations files.

[uwsgi]
chdir = /home/elastic/workspace/ES_Brevetti
wsgi-file = ES_Brevetti/wsgi.py
master = true
processes = 5
uid = nginx
gid = nginx
socket = unix:///socket/uwsgi.sock
chmod-socket = 666
vacuum = true

i've created the file /sockect/uwsgi.sock with permission 777

chown nginx:nginx -R /sockect/uwsgi.sock

and below nginx conf file:

upstream django {
    server unix:///socket/uwsgi.sock; # for a file socket
    #server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
    listen 80;
    server_name 10.184.2.231;
    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    charset utf-8;

    location /static/ { 
        alias /home/elastic/workspace/ES_Brevetti;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:///socket/uwsgi.sock;
    }
}

When i launch "systemctl start nginx" nginx is started with error: connect() to unix:///socket/uwsgi.sock failed (111: Connection refused) while connecting to upstream,

When i run uwsgi --ini /etc/uwsgi/sites/ES_Brevetti.ini it doesnt run with error:

.....
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Permission denied [core/socket.c line 230]

What i am doing wrong? On google i can only see configurations with VENV while i am not using virtual environment.

Upvotes: 0

Views: 2317

Answers (2)

user3779542
user3779542

Reputation: 29

The solution was change the socket = unix:///socket/uwsgi.sock to socket = /socket/uwsgi.sock in the uwsgi.ini file. I dont know why in some doc it appears the double slash for escaping.

Upvotes: -1

daphtdazz
daphtdazz

Reputation: 8159

The docs (which I'm guessing you were following) suggest that the socket configuration option in your uwsgi ini file should take a path to the socket, not a URL. Could you try changing:

[uwsgi]
...
socket = unix:///socket/uwsgi.sock

to

[uwsgi]
...
socket = /socket/uwsgi.sock

Upvotes: 1

Related Questions