Skip to content

Mongo::ConnectionFailure when pushing to EC2 #319

holgersindbaek opened this Issue Mar 28, 2013 · 15 comments

7 participants


Whenever I try to push to rubber, following the railscast tutorial - - to the point, it fails the push with this command:

** [out ::] /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in `connect': Failed to connect to a master node at (Mongo::ConnectionFailure)

I don't even use Mongo, I set the app up with postgresql and vulcanized with postgres as well.

This other people have had this issue before - #266 - but they weren't that good at explaining themselves.

This is the full stacktrace (beginning from the error):

 ** [out ::] /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in `connect': Failed to connect to a master node at (Mongo::ConnectionFailure)
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in `setup'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in `initialize'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in `new'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in `from_uri'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config/database.rb:89:in `master'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config/database.rb:22:in `configure'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config.rb:273:in `configure_databases'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config.rb:94:in `from_hash'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config.rb:109:in `block in load!'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config.rb:108:in `tap'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/config.rb:108:in `load!'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid.rb:147:in `load!'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mongoid-2.4.5/lib/mongoid/railtie.rb:84:in `block in <class:Railtie>'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
 ** [out ::] from /usr/local/graylog2-web-interface-0.9.6p1/config/environment.rb:6:in `<top (required)>'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands/runner.rb:40:in `<top (required)>'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:63:in `require'
 ** [out ::] from /usr/local/rubies/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:63:in `<top (required)>'
 ** [out ::] from ./script/rails:6:in `require'
 ** [out ::] from ./script/rails:6:in `<main>'
    command finished in 35898ms
failed: "/bin/bash -l -c 'sudo -p '\\''sudo password: '\\''  bash -l /tmp/bootstrap_graylog_web'" on
rubber member

Well you are depending on mongo since you're using graylog (I'm assuming that you vulcanized with one of the _complete templates). You need to add mongo to that node and re-bootstrap so graylog can properly initialize itself.


@SegFaultAX No I'm not. I'm using Postgrest and I'm vulcanixing using:

rubber vulcanize complete_passenger_postgresql

After that, graylog is automatically added to the gems. Am I doing something wrong here?

rubber member

Please note from the graylog template configuration:

description: The graylog log aggregation and search module
  - mongodb
  - elasticsearch

@SegFaultAX Ok... what does that mean? That I should take away graylog from the gemfile?

I've just tried to push using your quickstart guide and I get the same result. It would be great if you could update your quickstart, with the necessary steps. I'd love to get going with this awesome gem!


Seems like another guy is having a similar issue here:!topic/rubber-ec2/2RjzI3Gtius


@SegFaultAX Seems like these guys also has the same problem (just on ubuntu):



Seems like a lot of people are having this problem - Any fix?


If I do cap deploy afterwards, then it deploys and works fine, but this issue should probably be fixed.

rubber member

/cc @wr0ngway

samgrimm commented Apr 3, 2013

I am having the same problem, except the blog application (as in the railscast and the quick start guide) will not work after cap deploy. It looks like it does at first glance, but the tail logs show
Error: Port conflict: another instance is already running on /var/run/postgresql with port 5432



Same problem here. If I run "cap deploy" after a failed "cap rubber:create_staging" deployment I'll get the following error:

** [out ::] rake aborted!
** [out ::] could not connect to server: Connection refused
** [out ::] Is the server running on host "" ( and accepting
** [out ::] TCP/IP connections on port 5432?

This happens when I try to start the postgresql server to solve this problem:
ubuntu@production:~$ sudo /etc/init.d/postgresql start

  • Starting PostgreSQL 9.1 database server * Error: /mnt/postgresql/9.1/data is not accessible or does not exist

Any other ideas how to fix this Mongo::ConnectionFailure? The last time I deployed (4-5 months ago everything worked like a charm). Updated to latest rubber version.


Regarding the Mongo::ConnectionFailure problem:
I found this on stackoverflow: . This could be related to this problem - so I guess mongodb is not running.


Any news related to this problem?

kschutt commented Feb 12, 2014

Any progress here?

rubber member
nirvdrum commented Aug 7, 2014

I don't think this is an issue any longer. We've upgraded to graylog 0.20.x in Rubber and that version no longer uses a Rails app for the front-end. Mongo is still in use, but this whole bootstrapping problem should have gone away. If any of you could confirm, that'd be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.