Question
Nginx + Ruby On Rails = 504 Gateway Time-out
Hi there!
5th droplet attempt at DigitalOcean. I’ve followed all the steps provided by DigitalOcean guides (one click image etc…). I’ve uploaded my site by FTP, run bundle install, run rake db:migrate, I’ve even connected to my DB remotely and populated it with an old backup. Everything is perfect.
Except one thing. I haven’t been able to run my site not once. I get the classic “504 Gateway Time-out” error many have posted here although none has a response yet.
What is going on?
A few notes…
When running bundle install:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
nginx/error.log
2014/08/28 21:47:32 [error] 16805#0: *32 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 190.18.93.156, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "objectservers.com.ar"
log/unicorn.log
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler.rb:302: warning: Insecure world writable dir /home/rails in PATH, mode 040777
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler.rb:302: warning: Insecure world writable dir /home/rails in PATH, mode 040777
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler/runtime.rb:34:in `block in setup': You have already activated rack 1.6.0.beta, but your Gemfile requires rack 1.5.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler/runtime.rb:19:in `setup'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler.rb:121:in `setup'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler/setup.rb:17:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /home/rails/config/boot.rb:4:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/rails/config/application.rb:1:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/rails/config/environment.rb:2:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from config.ru:4:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.6.0.beta/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.6.0.beta/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.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `block in builder'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `build_app!'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:623:in `init_worker_process'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:643:in `worker_loop'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:527:in `spawn_missing_workers'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:538:in `maintain_worker_count'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:303:in `join'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/bin/unicorn:126:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p353/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>'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler/runtime.rb:34:in `block in setup': You have already activated rack 1.6.0.beta, but your Gemfile requires rack 1.5.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler/runtime.rb:19:in `setup'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler.rb:121:in `setup'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.7.2/lib/bundler/setup.rb:17:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /home/rails/config/boot.rb:4:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/rails/config/application.rb:1:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/rails/config/environment.rb:2:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from config.ru:4:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.6.0.beta/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.6.0.beta/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.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `block in builder'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `build_app!'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:623:in `init_worker_process'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:643:in `worker_loop'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:527:in `spawn_missing_workers'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:538:in `maintain_worker_count'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:303:in `join'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/bin/unicorn:126:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p353/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-08-28T21:52:49.144863 #32524] ERROR -- : reaped #<Process::Status: pid 4237 exit 1> worker=1
I, [2014-08-28T21:52:49.145159 #32524] INFO -- : worker=1 spawning...
E, [2014-08-28T21:52:49.145979 #32524] ERROR -- : reaped #<Process::Status: pid 4234 exit 1> worker=0
I, [2014-08-28T21:52:49.146203 #32524] INFO -- : worker=0 spawning...
I, [2014-08-28T21:52:49.147495 #4240] INFO -- : worker=1 spawned pid=4240
I, [2014-08-28T21:52:49.147709 #4240] INFO -- : Refreshing Gem list
I, [2014-08-28T21:52:49.151910 #4242] INFO -- : worker=0 spawned pid=4242
I, [2014-08-28T21:52:49.152180 #4242] INFO -- : Refreshing Gem list
I would really appreciate any help. It’s been days I’ve been meaning to finally try out DigitalOcean.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×