Problem:
Sometimes, sites running on uwsgi and nginx cannot find socket
file due to suddent restart of server. The most common error from /var/log/nginx/error.log
in this case is:
bind(): No such file or directory [core/socket.c line 230]
Content of Nginx config file:
Support, content of /etc/nginx/sites-enabled/demo_app.ini
is:
server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 80 default_server;
server_name example.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/ubuntu/app/demo_app/static/;
autoindex off;
location ~* \.(eot|ttf|woff|woff2)$ {
add_header 'Access-Control-Allow-Origin' '*';
}
}
location /media/ {
alias /home/ubuntu/app/demo_app/media/;
autoindex off;
}
location / {
add_header 'Access-Control-Allow-Origin' '*';
include uwsgi_params;
uwsgi_pass unix:/var/run/uwsgi/demo_app.sock;
}
}
Content of uwsgi config file:
And, content of etc/uwsgi/sites/demo_app.ini
file is:
project = demo_app
base = /home/ubuntu/app
chdir = %(base)/%(project)
home = %(base)/venv
module = conf.wsgi:application
env = DJANGO_SETTINGS_MODULE=conf.settings
master = true
processes = 5
socket = /var/run/uwsgi/%(project).sock
chmod-socket = 777
uid = www-data
gid = www-data
harakiri = 60
vacuum = true
buffer-size = 32768
logger = file:/tmp/uwsgi.log
log-maxsize = 200000
Solution:
After a reboot socket file inside /var/run/uwsgi/
gets lost, because no folder exists with name uwsgi
. That's why this folder is needed to be created.
mkdir /var/run/uwsgi
and
sudo chown -R www-data:www-data /var/run/uwsgi
Reference:
https://stackoverflow.com/questions/27791330/bind-no-such-file-or-directory-core-socket-c-line-230
Top comments (0)