Question

The difference between MongoDB Instance set up on a "MongoDB" single-click app vs a "MEAN" single click app

Posted June 14, 2015 6.4k views
MongoDBOne-Click Install AppsMEAN

Yesterday I ran into this problem:
http://stackoverflow.com/questions/30822370/authentication-always-failing-when-connecting-to-mongodb

I was confident I did everything right, but alas, had no luck. The MongoDB instance I was using in this case was an instance of MongoDB set up from the single-click-install app for Ubuntu 14.04.

After having no luck, I decided to install the MeanStack single click application. It worked out of the box so I figured I could just dissect it, see what it was doing, and what I was doing wrong. To my surprise though, I couldn’t find what I was doing wrong at all in terms of how I had set up my database query. I just popped in my own app, completely replacing the MEAN app provided with my own, and it worked perfectly with that MongoDB instance.

So this leaves the instance of MongoDB as the only difference. Something about the MongoDB set up with the “MongoDB” app, meant a query that would work in the Mean Stack" app didn’t work there. Surely, I must have missed something I was supposed to do in the MongoDB app that prevented any of my authentication-related queries from working.

So what are the differences between the two instances of MongoDB which would cause one to work while the other didn’t? (In this case, the MEAN stack app allowed me to plugin and go straight away, while the MongoDB app didn’t..)

6 comments
  • Hi,

    Can you share your /etc/mongod.conf so we can look at your settings? We operate mongodirector.com on DigitalOcean - so we have a lot of context on mongodb setup and can probably help you out.

  • Yes, here is the requested file (thank you!)

    mongod.conf

    Where to store the data.

    Note: if you run mongodb as a non-root user (recommended) you may

    need to create and set permissions for this directory manually,

    e.g., if the parent directory isn’t mutable by the mongodb user.

    dbpath=/var/lib/mongodb

    where to log

    logpath=/var/log/mongodb/mongod.log

    logappend=true

    port = 27017

    Listen to local interface only. Comment out to listen on all interfaces.

    bind_ip = 127.0.0.1

    Disables write-ahead journaling

    nojournal = true

    Enables periodic logging of CPU utilization and I/O wait

    cpu = true

    Turn on/off security. Off is currently the default

    noauth = true

    auth = true

    Verbose logging output.

    verbose = true

    Inspect all client data for validity on receipt (useful for

    developing drivers)

    objcheck = true

    Enable db quota management

    quota = true

    Set oplogging level where n is

    0=off (default)

    1=W

    2=R

    3=both

    7=W+some reads

    diaglog = 0

    Ignore query hints

    nohints = true

    Enable the HTTP interface (Defaults to port 28017).

    httpinterface = true

    Turns off server-side scripting. This will result in greatly limited

    functionality

    noscripting = true

    Turns off table scans. Any query that would do a table scan fails.

    notablescan = true

    Disable data file preallocation.

    noprealloc = true

    Specify .ns file size for new databases.

    nssize = <size>

    Replication Options

    in replicated mongo databases, specify the replica set name here

    replSet=setname

    maximum size in megabytes for replication operation log

    oplogSize=1024

    path to a key file storing authentication info for connections

    between replica set members

    keyFile=/path/to/keyfile

  • Hi,

    A few things

    1. bind_ip is only 127.0.0.1 - so you cannot connect to this instance from outside. You will need to comment out this line to access on other interfaces
    2. Can you comment out “noauth=true” and make sure “auth=true” is enabled to enable authentication
    3. if you using mongodb 3.0 please make sure you are using the mongo 3.0 client. There are changes in the authentication protocol that make the mongo 3.0 server incompatible with older version of mongo client.

    Hope that helps,
    Dharshan

    Founder Mongodirector.com

  • Thank you!

    As a side note, I was on the same server while doing this, though on different ports. My Mongo instance was on the default port (27071) and my Node/Express server was hosted on port 3000.

    Would the difference in port be significant?

    I know for at least the Mean app in which I got MongoDB to work, it appeared to have somehow mapped the Mongo instance to be referenced from the root IP address. Perhaps this made the difference?

  • Hi,

    If you follow steps 1. and 2. I mentioned above, you should be good. Remember to restart the mongo service after this - “service mongod restart” on CentOS. Equivalent on your distro

  • Show 1 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

This question was answered by @scalegrid:

Hi,

A few things

  1. bind_ip is only 127.0.0.1 - so you cannot connect to this instance from outside. You will need to comment out this line to access on other interfaces
  2. Can you comment out “noauth=true” and make sure “auth=true” is enabled to enable authentication
  3. if you using mongodb 3.0 please make sure you are using the mongo 3.0 client. There are changes in the authentication protocol that make the mongo 3.0 server incompatible with older version of mongo client.

Hope that helps,
Dharshan

Founder Mongodirector.com

View the original comment

Submit an Answer