Nginx 502 error after power cycle.

July 20, 2014 2.8k views

I set up the 1 click droplet with Ubuntu and Rails. After setting up Git and uploaded the project I worked on it for some weeks without any problem. Then I did a power cycle from the DigitalOcean web UI and since then I got the 502 error.

I've tried everything, rebooting from UI, rebooting from the console, changing permissions on the project to the same user as nginx, rebooting nginx, rebooting unicorn, but until now nothing worked.

Any suggestions on resolving this?

2 Answers

Each request to the root will give me a bunch of permission denied errors in the nginx error logs:

2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public//index.html" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET / HTTP/1.1", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET / HTTP/1.1", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 connect() to unix:/tmp/unicorn.test_app.sock failed (2: No such file or directory) while connecting to upstream, client: 85.242.64.133, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/500.html/index.html" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/500.html" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 connect() to unix:/tmp/unicorn.test_app.sock failed (2: No such file or directory) while connecting to upstream, client: 85.242.64.133, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/500.html", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/favicon.ico/index.html" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/favicon.ico" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 connect() to unix:/tmp/unicorn.test_app.sock failed (2: No such file or directory) while connecting to upstream, client: 85.242.64.133, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/favicon.ico", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/500.html/index.html" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/favicon.ico", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 stat() "/root/test_app/public/500.html" failed (13: Permission denied), client: 85.242.64.133, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/favicon.ico", host: "188.226.135.29"
2014/07/20 22:43:17 [crit] 1219#0: *48 connect() to unix:/tmp/unicorn.test_app.sock failed (2: No such file or directory) while connecting to upstream, client: 85.242.64.133, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/tmp/unicorn.test_app.sock:/500.html", host: "188.226.135.29"

One the one-click Rails app, unicorn is launched with the rails user.

# cat /home/unicorn/unicorn.conf
listen "127.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "/home/rails"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"

What are the permissions on /root/test_app/? The sample application that is running on the one-click app is in /home/rails/ Usually people just remove the contents of that directory and install their app there.

Have another answer? Share your knowledge.