1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Nginx で「onnect() to /hoge.sock failed (13: Permission denied)」の対処法

Posted at

発生問題

Nginxを起動させ、アクセスしたらBad Gatewayと言われた。

エラーログを見るとPermissionエラー。

*2 connect() to unix:/home/hoge.sock failed (13: Permission denied) while 
connecting to upstream, client:192.168.1.170, server: 192.168.1.180, 
request: "GET / HTTP/1.1", upstream: "http://unix:/home/hoge.sock:/"

開発環境

CentOS7
Nginx
Gunicorn
Django3.2.20

原因

  • .sockファイルがNginxからアクセスできない場所に置かれている
  • SELinuxのファイルアクセス制御によってアクセスできない

解決策

  • SELinuxを一時無効化させる
setenforce 0
  • .sockファイルを/var/run/などNignxからアクセスできる場所に作成する

nginx.confのuserをrootにするとアクセス出来ますが、セキュリティ上、危険なのでやめましょう

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?