wbetin
By:
wbetin

504 Gateway Time-out nginx (Rails with Ubuntu 14, NGINX + Unicorn)

May 22, 2015 3.4k views
Nginx One-Click Install Apps Deployment Ruby on Rails DigitalOcean Articles Ubuntu

Just created a new droplet on Ubuntu 14 with One-click Rails (nginx + unicorn) and I'm not that good in playing with this kind of configuration, but reading some of the digitalocean articles I tried to clone my app from my bitbucket repository, in a new user aside the already created 'rails' - because I didn't wanted to change the name of the app (what a fool I am) - and I have started facing some problems with that (create new user, new main directory, change unicorn files, etc). I also installed ruby 2.2.1 and rails 4.2.1 (versions which I'm using in my app) through rvm, so I had to change all that unicorn files (/home/unicorn/unicorn.conf, /etc/default/unicorn, /usr/local/rvm/gems/ruby-2.2.1@rails4.2.1/bin/unicorn, /etc/init.d/unicorn), like I saw I in some of the articles. Right after it was alright - at least when I was thinking it was alright - Nginx started giving me this problems. The log is showing very strange links that I have no clue from what it is coming (my app domain is saladapronta.com, nothing about "www.techtelling.com"). Look:

var/log/nginx/error.log

2015/05/22 22:34:46 [error] 15278#0: *34 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 180.76.15.9, server: _, request: "GET /news/google-intros-the-first-android-one-smartphone-for-europe-general-mobile-4g HTTP/1.1", upstream: "http://127.0.0.1:8080/news/google-intros-the-first-android-one-smartphone-for-europe-general-mobile-4g", host: "www.techtelling.com" 
2015/05/22 22:35:17 [error] 15278#0: *43 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.64.52, server: _, request: "GET /news/sony-nabs-cloud-gamers-onlive-administers-swift-headshot HTTP/1.1", upstream: "http://127.0.0.1:8080/news/sony-nabs-cloud-gamers-onlive-administers-swift-headshot", host: "www.techtelling.com" 
2015/05/22 22:35:22 [error] 15278#0: *5 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.75.72, server: _, request: "GET /news/noble-adds-some-wireless-spice-to-existing-earphones HTTP/1.1", upstream: "http://127.0.0.1:8080/news/noble-adds-some-wireless-spice-to-existing-earphones", host: "www.techtelling.com" 
2015/05/22 22:36:12 [emerg] 19543#0: unknown directive "sendtimeout" in /etc/nginx/nginx.conf:32 
2015/05/22 22:36:17 [error] 15278#0: *3 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.75.80, server: _, request: "GET /news/area-51trailer-is-a-psa-for-notbreaking-into-topsecret-military-bases HTTP/1.1", upstream: "http://127.0.0.1:8080/news/area-51trailer-is-a-psa-for-notbreaking-into-topsecret-military-bases", host: "www.techtelling.com" 
2015/05/22 22:36:22 [error] 15278#0: *5 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.75.72, server: _, request: "GET /news/china-to-delay-bank-tech-restrictions-us-treasury-official-says HTTP/1.1", upstream: "http://127.0.0.1:8080/news/china-to-delay-bank-tech-restrictions-us-treasury-official-says", host: "www.techtelling.com" 
2015/05/22 22:37:06 [emerg] 20301#0: unknown directive "proxyread_timeout" in /etc/nginx/nginx.conf:33 
2015/05/22 22:37:17 [error] 15278#0: *64 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.75.72, server: _, request: "GET /news/twitters-earnings-leak-is-latest-sign-that-good-bots-are-going-too-far HTTP/1.1", upstream: "http://127.0.0.1:8080/news/twitters-earnings-leak-is-latest-sign-that-good-bots-are-going-too-far", host: "www.techtelling.com" 
2015/05/22 22:37:22 [error] 15278#0: *5 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.75.72, server: _, request: "GET /news/bradley-cooper-joins-limitless-tv-show HTTP/1.1", upstream: "http://127.0.0.1:8080/news/bradley-cooper-joins-limitless-tv-show", host: "www.techtelling.com" 
2015/05/22 22:38:17 [error] 15278#0: *64 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 66.249.75.72, server: _, request: "GET /news/rust-experiments-with-racial-empathy-randomly-assigns-skin-color HTTP/1.1", upstream: "http://127.0.0.1:8080/news/rust-experiments-with-racial-empathy-randomly-assigns-skin-color", host: "www.techtelling.com"

There's also the /home/unicorn/log/unicorn.log

I, [2015-05-22T23:46:47.834267 #17180]  INFO -- : worker=1 spawning...
I, [2015-05-22T23:46:47.835121 #8056]  INFO -- : worker=2 spawned pid=8056
E, [2015-05-22T23:46:47.840075 #17180] ERROR -- : reaped #<Process::Status: pid 8050 exit 1> worker=3
I, [2015-05-22T23:46:47.840263 #17180]  INFO -- : worker=3 spawning...
I, [2015-05-22T23:46:47.841347 #8059]  INFO -- : worker=1 spawned pid=8059
I, [2015-05-22T23:46:47.842449 #8062]  INFO -- : worker=3 spawned pid=8062
I, [2015-05-22T23:46:47.858317 #8054]  INFO -- : Refreshing Gem list
I, [2015-05-22T23:46:47.859726 #8056]  INFO -- : Refreshing Gem list
I, [2015-05-22T23:46:47.862033 #8059]  INFO -- : Refreshing Gem list
I, [2015-05-22T23:46:47.870040 #8062]  INFO -- : Refreshing Gem list

I've readed the existent questions and answers with this similar problem but none of the solutions I've tested worked for me.

2 comments
  • Now there's a lot of errors showing on unicorn log like:
    (I had to run 'tail -20 /home/unicorn/log/unicorn.log' because without that '-20' it shows infinite errors)

            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.1/lib/rack/builder.rb:55:in `initialize' 
            from config.ru:1:in `new' 
            from config.ru:1:in `<main>' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `eval' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `block in builder' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `call'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in  `build_app!' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:632:in `init_worker_process' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:655:in `worker_loop' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:529:in `spawn_missing_workers' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:540:in `maintain_worker_count' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:294:in `join' 
            from /usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>' 
            from /usr/local/rvm/gems/ruby-2.2.1/bin/unicorn:23:in `load' 
            from /usr/local/rvm/gems/ruby-2.2.1/bin/unicorn:23:in `<main>' 
            from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval' 
            from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>' 
    E, [2015-05-24T05:09:44.341623 #4517] ERROR -- : reaped #<Process::Status: pid 7865 exit 1> worker=0 
    E, [2015-05-24T05:09:44.444091 #4517] ERROR -- : reaped #<Process::Status: pid 7893 exit 1> worker=1 
    I, [2015-05-24T05:09:44.444339 #4517] INFO -- : master complete
    
  • Hi,

    did you work this out?
    I have exactly the same issue and would love to hear from you if you have find a solution.

    I had also to run 'tail -20 /home/unicorn/log/unicorn.log' and CPU usage is 100%..

    Thanks!

1 Answer

Did you fixed it? I have the same error...

Have another answer? Share your knowledge.