Nginx 13: Permission denied solution

  • 2020-05-15 03:31:50
  • OfStack

Today, I encountered a 502 error when deploying the flask application with uwsgi+nginx. vim /var/log/nginx/error.log Check the nginx error log and see the following error message:

[

2018/07/22 00:46:36 [crit] 15890#15890: *74 connect() to unix:/root/jianshuvue/jianshu.sock failed (13: Permission denied) while connecting to upstream, client: 120.42.13.98, server: jianshu.weiweiblog.cn, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/root/jianshuvue/jianshu.sock:", host: "jianshu.weiweiblog.cn", referrer: "http://jianshu.weiweiblog.cn/jianshu/67eb7ed414d3"

]

Permission, denied, 1 you can tell it's a permission problem, pass ps -ef | grep nginx , to view the process information of nginx:

[

root 15889 1 0 00:01 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 15890 15889 0 00:01 ? 00:00:00 nginx: worker process
root 16795 15654 0 00:48 pts/3 00:00:00 grep --color=auto nginx

]

Find user is nginx nginx process, and we create/root jianshuvue/jianshu sock file users is root, therefore, as long as the process of nginx user root can instead, vim /etc/nginx/nginx.conf:


# user www-data;
user root;
worker_processes auto;
pid /run/nginx.pid;

after ,/etc/init.d/nginx restart Restart nginx and you can access the website normally.


Related articles: