I can connect just fine to a local MongoDB, but when I try connecting to either MongoHQ or DotCloud instance using Ruby Mongoid, then I get the above error message.
I'm using Ruby 1.9.3 and Moped 1.5.2.
I can connect to MongoHQ and DotCloud DBs using MongoHub Mac client.
I've tried using irb to debug by doing the following:
> require 'Mongoid'
> class Page
> include Mongoid::Document
> field :title, type: String
> end
> Mongoid.sessions = {default: {hosts: ["mongodb://<username>:<password>@troup.mongohq.com:10067"], database: "test"}}
> hello = Page.new
> hello.title = "Try this."
> hello.save
This results in the "Could not resolve IP..." error message.
Do you know what I'm missing. Or any tips for debugging this issue?
Thanks
Change this line
Mongoid.sessions = {default: {hosts: ["mongodb://<username>:<password>@troup.mongohq.com:10067"], database: "test"}}
to and give your username and password below
Mongoid.sessions = {default: {uri: ["mongodb://<username>:<password>@troup.mongohq.com:10067/test"]}}
if you are going to hosts, in that uri hosts is troup.mongohq.com:10067
port is 10067, database test and for authentication username and password...