in Server

Nodejs Nginx error: failed (13: Permission denied) while connecting to upstream

5.00
1 Star2 Stars3 Stars4 Stars5 Stars
Ratings: 5.00/5 from 5 users.
Loading...

Using Nodejs and Nginx you can get this error: failed (13: Permission denied) while connecting to upstream error can display when trying to run a Nodejs application on Nginx server on some ports, you may get an error in the browser. so firstly you should check the error logs:

tail -f /var/log/nginx/error.log

2016/04/24 18:30:56 [crit] 9879#0: *1 connect() to 192.186.1.6:8081 failed (13: Permission denied) while connecting to upstream, client: 192.186.1.33, server: default, request: “GET / HTTP/1.1”, upstream: “http://192.186.1.6:8081/”, host: “192.186.1.6”

also check :
/var/log/audit/audit.log

may be the issue will be due to SELinux.

so check for errors in the SELinux logs:

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

Running the following commands fixed my issue:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
sudo semodule -i mynginx.pp

References:

http://blog.frag-gustav.de/2013/07/21/nginx-selinux-me-mad/ https://wiki.gentoo.org/wiki/SELinux/Tutorials/Where_to_find_SELinux_permission_denial_details http://wiki.gentoo.org/wiki/SELinux/Tutorials/Managing_network_port_labels http://www.linuxproblems.org/wiki/Selinux

Add a Comment

Your email address will not be published. Required fields are marked *