[Solved] Cannot connect to MongoDB

Hi,

I’ve started using meteor recently. When I run the built bundle with environment variable MONGO_URL= mongodb://username:password@127.0.0.1:27017/meteor?authSource=admin&autoReconnect=true. (authSource is required but autoReconnect didn’t make any difference) the application establishes a connection to mongod but it fails in approx 2 secs and it fallbacks to localhost:3001 and tries to connect to that port (but nothing is up on port 3001)

I run mongod in verbose mode, to be exact (sudo mongod --auth -vv --bind_ip_all), the following is the logs of failed queries and network error occured

2019-02-18T23:42:46.026+0100 I COMMAND [conn14] command meteor.users command: listIndexes { listIndexes: “users”, cursor: {}, lsid: { id: UUID(“ab89ee2f-5277-47c9-aa57-0561846d7d48”) }, $db: “meteor” } numYields:0 reslen:1472 locks:{ Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 0ms
2019-02-18T23:42:47.116+0100 D WRITE [startPeriodicThreadToAbortExpiredTransactions] Beginning scanSessions. Scanning 0 sessions.
2019-02-18T23:42:47.377+0100 D COMMAND [conn14] run command meteor.$cmd { find: “external_operators”, filter: {}, returnKey: false, showRecordId: false, lsid: { id: UUID(“264814b4-60a7-4c7c-ab6d-55e367ac2fd8”) }, $db: “meteor” }
2019-02-18T23:42:47.377+0100 D QUERY [conn14] Collection meteor.external_operators does not exist. Using EOF plan: query: {} sort: {} projection: {}
2019-02-18T23:42:47.377+0100 I COMMAND [conn14] command meteor.external_operators command: find { find: “external_operators”, filter: {}, returnKey: false, showRecordId: false, lsid: { id: UUID(“264814b4-60a7-4c7c-ab6d-55e367ac2fd8”) }, $db: “meteor” } planSummary: EOF keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:0 nreturned:0 reslen:129 locks:{ Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 0ms
2019-02-18T23:42:47.381+0100 D COMMAND [conn14] run command meteor.$cmd { listIndexes: “users”, cursor: {}, lsid: { id: UUID(“ab89ee2f-5277-47c9-aa57-0561846d7d48”) }, $db: “meteor” }
2019-02-18T23:42:47.381+0100 I COMMAND [conn14] command meteor.users command: listIndexes { listIndexes: “users”, cursor: {}, lsid: { id: UUID(“ab89ee2f-5277-47c9-aa57-0561846d7d48”) }, $db: “meteor” } numYields:0 reslen:1472 locks:{ Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 0ms
2019-02-18T23:42:47.398+0100 D NETWORK [conn14] Session from 127.0.0.1:61702 encountered a network error during SourceMessage

I am having this issue on macOS High Sierra (10.13.6), meteor version 1.8.0.2
What am I missing?

Thanks

Can you connect to the mongodb instance from the command line?

Yes, I can and the connection is stable in that case. This problem also occurs when I launch mongodb in docker container

Edit: I make it work when I start mongodb on port 3001, but still I don’t see why it doesn’t work on port 27017, or any other port. I guess somehow I couldn’t overwrite default settings. But as I said earlier, it establishes a connection for short amount of time in startup.