Ngix - 502 Bad Gateway after changing root password

October 27, 2014 2.4k views

I have a Bad Gateway issue on a Ruby on Rails environment and I know absolutely nothing about Ruby. I am going to be running an app for a week and a half and had this app setup by a contracted whom is not available.

Sorry if there is an answer somewhere already, everything I seen was for PHP environments and I need to solve this in 24 hours before we launch our campaign, so in a bit of panic situation.

The VPS it's running on:

104.131.241.16 | http://invite.teachtomarket.com
Ruby on Rails on 14.04 (Nginx + Unicorn)

What happened before it last

I couldn't get into the server via FTP or SSH, so I reset the root password. I'm assuming this caused the issue because the site went down right after.

Additional Information

In case it matters, the domain is run through GoDaddy and with an A record pointing to the IP address.

I have, no idea what to do next.

1 Answer

502 means that whatever is behind NGINX went down (in your case, rails). A root password reset may have restarted your server and you haven't set your rails application up to start on boot.

  • Okay, so what do I do next? Any articles you can link me to. As mentioned before, I know nothing and I'm short on time. I really appreciate the help.

    What I know so far is that I have cd into the application at /home/rails/ and then I run rails server and it reports back to me as if it's running but I still have the Bad Gateway.

  • @darcyvoutt: Are there any errors in nginx's and unicorn's error logs?

    sudo tail /var/log/nginx/error.log /home/unicorn/log/unicorn.log
    
  • @kamain7 I've gotten a bit of help from someone on Stackoverflow, whom is not available this moment, this is where I'm at now. We been able to determine the 502 bad gateway was due to the directory the nginx is to point to was commented out in an config file.

    Though right now I'm getting a 504 Gateway Time-out, here are error messages based on the tails you asked me to pull up:

    For the nginx error.log:

    Here's a few of the last errors, there are more that look redundant.

    2014/10/27 14:18:56 [error] 622#0: *33 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 84.45.119.6, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "invite.teachtomarket.com", referrer: "http://chat.stackoverflow.com/rooms/63697/discussion-between-broisatse-and-dvoutt"
    2014/10/27 19:10:51 [error] 622#0: *36 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 209.29.23.26, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "invite.teachtomarket.com"
    2014/10/27 19:14:41 [error] 622#0: *38 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 209.29.23.26, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "invite.teachtomarket.com"
    
    

    For the unicorn.log

    After reading this I did a gem update when seeing the "Refreshing Gem list", but no avail.

    from /usr/local/rvm/gems/ruby-2.1.3/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:294:in `join'
        from /usr/local/rvm/gems/ruby-2.1.3/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.1.3/bin/unicorn:23:in `load'
        from /usr/local/rvm/gems/ruby-2.1.3/bin/unicorn:23:in `<main>'
        from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
    E, [2014-10-27T19:16:27.402981 #1360] ERROR -- : reaped #<Process::Status: pid 30622 exit 1> worker=1
    I, [2014-10-27T19:16:27.403291 #1360]  INFO -- : worker=1 spawning...
    I, [2014-10-27T19:16:27.415930 #30634]  INFO -- : worker=1 spawned pid=30634
    I, [2014-10-27T19:16:27.447225 #30634]  INFO -- : Refreshing Gem list
    
    
Have another answer? Share your knowledge.