502 Bad Gateway on one-click Ruby Rails app

December 25, 2016 708 views
Ruby on Rails Ubuntu 16.04

Hi I've been following the deploy your rails app with one click. I've tried to deploy my rails app after many several attempts. Any idea what I might be missing or doing wrong? I've been following the "How to Use the Ruby on Rails One-Click Application on DigitalOcean" very closely. Thanks!

when I run sudo tail -30 /var/log/nginx/error.log I get

2016/12/24 22:45:39 [error] 19842#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 99.57.138.78, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "192.241.137.121"
2016/12/24 22:48:21 [error] 21366#0: *23 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 99.57.138.78, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "192.241.137.121"
2016/12/24 22:49:10 [error] 21366#0: *25 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 99.57.138.78, server: _, request: "GET /todo_lists/index HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/todo_lists/index", host: "192.241.137.121"
2016/12/24 22:50:42 [error] 21366#0: *28 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 99.57.138.78, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "192.241.137.121"
2016/12/24 22:55:17 [error] 21366#0: *31 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 99.57.138.78, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "192.241.137.121"
2016/12/24 22:55:57 [error] 21366#0: *31 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 99.57.138.78, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock:/", host: "192.241.137.121"
1 Answer

First make sure Unicorn is running. Verify it's service by running:

  • sudo systemctl status unicorn

You should see there running somewhere.

Beside that you can take a lot at Unicorn logs which should be located in /var/log/unicorn/unicorn.log.

If everything is OK, we will try to find more clues. =)

Have another answer? Share your knowledge.