mozilla

Mongo Connection Issue


#1

Hi all,

I have following setup:

  • Mongo is running on host 10.0.0.6
  • Redis is running somewhere else (not important for this question)
  • Talk is running on localhost in a docker file

Trying to connect from the local machine to mongo works as expected.

 mongo  --host 10.0.0.6 --port 27017
   MongoDB shell version v3.6.4
   connecting to: mongodb://10.0.0.6:27017/
   MongoDB server version: 3.6.4
   >

When trying to run my docker instance with

sudo docker run -d -t -i -e 'NODE_ENV=development' -e 'TALK_MONGO_URL=mongodb://10.0.0.6:27017/talk' ...

I can see in the logs the following error message:

{ MongoError: not authorized on talk to execute command { listIndexes: "actions", cursor: {}, $db: "talk" }
    at Function.MongoError.create (/usr/src/app/node_modules/mongodb-core/lib/error.js:31:11)
    at queryCallback (/usr/src/app/node_modules/mongodb-core/lib/cursor.js:212:36)
    at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'MongoError',
  message: 'not authorized on talk to execute command { listIndexes: "actions", cursor: {}, $db: "talk" }',
  ok: 0,
  errmsg: 'not authorized on talk to execute command { listIndexes: "actions", cursor: {}, $db: "talk" }',
  code: 13,
  codeName: 'Unauthorized' }
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c NODE_ENV=production ./bin/cli-serve -j -w
Directory: /usr/src/app
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/usr/src/app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Connection from Talk doesn´t work. Now I tried to play around:

  • I created the talk database by my own

  • I created a user with name + passsword and grant the role dbAdmin on the talk database

  • I run docker again

    sudo docker run -d -t -i -e ‘NODE_ENV=development’ -e ‘TALK_MONGO_URL=mongodb://test:test@10.0.0.6:27017/talk’

Same error message in the docker logs before. Also connecting to mongo with cli doesn´t work for me.

mongo -u "test" -p "test" --authenticationDatabase "talk" --host 10.0.0.6 --port 27017
MongoDB shell version v3.6.4
connecting to: mongodb://10.0.0.6:27017/
MongoDB server version: 3.6.4
2018-05-09T15:17:19.926+0000 E QUERY    [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1608:20
@(auth):6:1
@(auth):1:2
exception: login failed

I am not an Mongo expert (as you have probably already thought) why I am asking you for support.

I am happy for every hint that could help.