Wednesday, November 7, 2018

Centos 7: uwsgi.sock failed (13: Permission denied) while connecting to upstream. How to fix.

In centos i had this issue in my nginx error.log:

uwsgi.sock failed (13: Permission denied) while connecting to upstream, client: ...

After searching a bit, I found that this is because of centos SELinux permissions.

To check if that's the case, you can run this command and see if there is any output:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied

If you see some lines like this:
type=AVC msg=audit(1541573465.479:2305575): avc:  denied  { write } for  pid=24106 comm="nginx" name="uwsgi.sock" dev="xvda1" ino=18611048 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:usr_t:s0 tclass=sock_file
type=AVC msg=audit(1541573470.018:2305576): avc:  denied  { write } for  pid=24106 comm="nginx" name="uwsgi.sock" dev="xvda1" ino=18611048 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:usr_t:s0 tclass=sock_file
type=AVC msg=audit(1541573480.698:2305583): avc:  denied  { write } for  pid=24106 comm="nginx" name="uwsgi.sock" dev="xvda1" ino=18611048 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:usr_t:s0 tclass=sock_file

Then you can fix it like this:
sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
sudo semodule -i mynginx.pp
sudo systemctl restart nginx

Source link

No comments:

Post a Comment