What should be the Host Name for MongoDB created using Bitnami - Getting Authentication Failed

178 views
Skip to first unread message

Kriti das

unread,
Feb 3, 2017, 11:48:42 PM2/3/17
to Google App Engine
I have deployed the MongoDb using the Google cloud Launcher and BITNAMI. I got the username and password from the deployment console. 

I used the keys.json for the credentials in nodejs application -

{
  "mongoHost": "104.198.142.198",
  "mongoPort": "27017",
  "mongoDatabase": "transM",
  "mongoUser": "root",
  "mongoPass": "secret"
}

My App.js -

const username = nconf.get('mongoUser');
const pass = nconf.get('mongoPass');
const host = nconf.get('mongoHost');
const port = nconf.get('mongoPort');

let uri = `mongodb://${username}:${pass}@${host}:${port}`;

if (nconf.get('mongoDatabase')) {
  uri = `${uri}/${nconf.get('mongoDatabase')}`;
}

console.log(uri);

mongoose.connect(uri);
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
    // we're connected!
    console.log("Connected correctly Database to server");
});


The stderr log shows Authentication fails. But when I try remote connection using the same in terminal -

mongo admin --username root -p --host 104.198.142.198 --port 27017


it lets me log in.


Please note -


In the example by google the mlabs hostname is used -


https://cloud.google.com/nodejs/resources/databases/mongodb

{
 
"mongoHost": "ds053894.mlab.com",
 
"mongoPort": "53894",
 
"mongoDatabase": "mydata",
 
"mongoUser": "myapp",
 
"mongoPass": "mypword",
}



{

 
"mongoHost": "ds053894.mlab.com",
 
"mongoPort": "53894",
 
"mongoDatabase": "mydata",
 
"mongoUser": "myapp",
 
"mongoPass": "mypword",
}

Can you please help to get the correct host name for BITNAMI Mongo instance.

Adam (Cloud Platform Support)

unread,
Feb 4, 2017, 7:19:59 PM2/4/17
to Google App Engine
If you want the IP address of your MongoDB cluster that you just deployed to Compute Engine using Cloud Launcher, look at the VM instances in your project to see what the IP addresses are.

That other doc you linked to talks about using mLab as an alternative to running your own MongoDB instances, which is why it references the mLab hostname as an example. It's important to read the wording of the documentation carefully. It can be tempting to try and blaze through a tutorial to get something working, but details are important.

If you are still getting an error in stderr, please post the full error message so that people can be properly enabled to help you, otherwise we must assume that you've interpreted the error correctly.

Kriti das

unread,
Feb 4, 2017, 10:28:44 PM2/4/17
to Google App Engine

This is exactly what I gave in the previous post (please refer again) -

{
  "mongoHost": "104.198.142.198",
  "mongoPort": "27017",
  "mongoDatabase": "transM",
  "mongoUser": "root",
  "mongoPass": "secret"
}

The field 'mongoHost' points to the IP address of the VM Instance of the mongoDB created by BITNAMI. Please read my previous post once more in detail.
This did not work. The authentication of Mongo failed with code-18. When I shifted to mlabs, and gave their hostname, it worked.

Let me know if you need any more info.

Thanks
Kriti

Adam (Cloud Platform Support)

unread,
Feb 6, 2017, 2:16:59 PM2/6/17
to Google App Engine
Your question was how to get the hostname of the Bitnami MongoDB instance. You could have had the wrong IP - there wasn't enough information to tell - but if you're getting it from the GCE VM instance list you can be sure it's the correct one.

If you're getting 'code-18' it seems to indicate a permissions issue with the database, rather than an issue with the hostname. Rather than troubleshooting the Bitnami image you might try using the Google click-to-deploy solution which has more configuration options out of the box.
Reply all
Reply to author
Forward
0 new messages