user4209821
user4209821

Reputation:

failed to connect to mongoose lab

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

Answers (2)

Disposer
Disposer

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

enter image description here

Updated: Test your connection via robomongo

Connect to mongolab via robomongo

Step 1: create new connection

enter image description here

Step 2: enter your address ds063200.mongolab.com and 61200 as your port

enter image description here

Step 3: enter flights as your database and your database user and password ('not mongolab user and password)

enter image description here

Upvotes: 3

low_rents
low_rents

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

Related Questions