Nginx getting Permission denied when connecting to Unicorn

前端 未结 3 1458
旧巷少年郎
旧巷少年郎 2021-01-20 03:24

I have tried many suggestions online but nothing has worked. I have unicorn and nginx working to deploy a ruby on rails app on a CentOS 6.5 server. It has worked before b

相关标签:
3条回答
  • 2021-01-20 03:33

    I faced a 502 Bad Gateway issue just yesterday on my Ubuntu 12.10 and nginx and unicorn. These type of errors are too generic so the best I can do is help you find more details about underlying error. In my case, I was able to determine the cause by viewing the end of my unicorn log file.

    tail -n 100 /home/unicorn/log/unicorn.log
    

    Your unicorn log may be located somewhere else, I'm on a Digital Ocean server with the rails app setup. But I do think you will find the cause of the error you are receiving in your unicorn log file. If not, check your nginx error log.

    In my case, I had conflicted gem versions between system gems and my app (unicorn is not running under bundle exec, on my todo) but your issue may be something else. The logs will help you figure out the cause of the 502 Bad Gateway.

    0 讨论(0)
  • 2021-01-20 03:37

    I had this problem recently. Unicorn was being executed correctly and its error's log was fine. Nginx's error log was showing "failed 13: Permission denied" messages. As many other users, I checked the permissions of the unicorn.sock file and they were correct.

    The problem was that not only the unicorn.sock file needs the correct permissions; also the whole path to the unicorn file needs to have readable permissions.

    chmod o+r
    

    After changing the permissions on those folders, the magic happened.

    0 讨论(0)
  • I found the problem. The path for unicorn.myapp.sock had to go to the /tmp directory on root rather than in myuser directory. Also, the root path in my nginx default.conf file needed to be at root/myApp/public rather than what I had. I have no idea what that last part means but it works and I'm happy. Thanks to everyone that helped me get here.

    0 讨论(0)
提交回复
热议问题