connect() failed (111: Connection refused)
的有关信息介绍如下:nginx+uwsgi+django,nginx日志报错: connect() failed (111: Connection refused) while connecting to upstream
出现此错误提示,表明uwsgi.ini或nginx.conf有问题,导致nginx 访问uwsgi被拒绝
解决方法:
1、检查uwsgi.ini
[uwsgi]
socket = 127.0.0.1:8077
chdir = /root/env/demo
wsgi-file = demo/wsgi.py
processes = 2
threads = 4
chmod-socket = 664
vacuum = true
2、检查nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
charset utf-8;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
location / {
root /root/env/demo;
include /etc/nginx/uwsgi_params;
uwsgi_pass 127.0.0.1:8077;
}
location /static {
alias /root/env/ht/collected_static;
}
location /media {
alias /root/env/ht/media;
}
}
如果上述还不能解决问题,查看SELinux状态:
#getenforce
用于解决:failed(13:Permissiondenied)whileconnectingtoupstream
如果SELinux status参数为enabled即为开启状态
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled