Reputation:
Ive create mongoose lab DB and Im getting error in the command line that it failed to connect(i've provided the right user and pass),what am I doing wrong and how can I overcome this issue?
mongoose.connect('mongodb://myuser:[email protected]:61200/flights',function(err){
if(err) throw err;
})
im using node.js
Upvotes: 1
Views: 147
Reputation: 6371
I believe you are using your MongoLab's username
& password
for connecting to your database.
You should define a username & password for your database in MongoLab control panel
for example I have a database named 'test'
, after login to Mongolab I'll go to https://mongolab.com/databases/test#users and add new username and password for 'test'
database
username: hamid, password:zzzz
.
the connection for test database
my mongolab will be
mongodb://hamid:[email protected]:53438/test
Updated: Test your connection via robomongo
Connect to mongolab
via robomongo
Step 1: create new connection
Step 2: enter your address ds063200.mongolab.com
and 61200
as your port
Step 3: enter flights
as your database and your database user and password ('not mongolab user and password)
Upvotes: 3
Reputation: 4481
it's just a guess since i never used mongoose so far - but i can't seem to find a connection string with a callback in the mongoose docs: http://docs.mongodb.org/manual/reference/connection-string/
so maybe the connection function doesn't support a callback and you are just fine with this:
mongoose.connect('mongodb://myuser:[email protected]:61200/flights');
Upvotes: 0