MongoServerSelectionError with Node client and local installation on Ubuntu 20.04

I’m trying to connect to a local instance of MongoDB 6.0.6 (no replica set) via the MongoDB Node client. I’m getting the following error:

{
  "message":"connection timed out",
  "name":"MongoServerSelectionError",
  "stack":"MongoServerSelectionError: connection timed out
    \n    at Timeout._onTimeout (…/node_modules/mongodb/src/sdam/topology.ts:567:30)
    \n    at listOnTimeout (node:internal/timers:569:17)
    \n    at processTimers (node:internal/timers:512:7)"
},
"msg":"connection timed out","time":"2023-07-06T16:23:22.142Z",
"v":0
}

the corresponding MongoDB log output is:

{"t":{"$date":"2023-07-06T18:23:22.093+02:00"},
"s":"I",
"c":"NETWORK",
"id":22943,
"ctx":"listener",
"msg":"Connection accepted","attr":{"remote":"127.0.0.1:41396","uuid":"0bc27e00-4dcc-4b3d-98d9-5fd4b8f58128","connectionId":8,"connectionCount":2}}
{"t":{"$date":"2023-07-06T18:23:22.104+02:00"},
"s":"I",  "c":"NETWORK",
"id":22944,
"ctx":"conn8",
"msg":"Connection ended","attr":{"remote":"127.0.0.1:41396","uuid":"0bc27e00-4dcc-4b3d-98d9-5fd4b8f58128","connectionId":8,"connectionCount":1}}

I’m using the following config for the MongoDB isntance:

net:
  ipv6: true
  bindIp: '127.0.0.1'
  port: 27017
storage:
  journal:
    enabled: true
security:
  authorization: 'disabled'

and the node client options are:
new MongoClient('mongodb://127.0.0.1:27017', { directConnection: true })

Hey @Sebastian_Luksic,

Thank you for reaching out to the MongoDB Community forums.

I suspect the format of the configuration file is not correct, as the bindIp does not need to be enclosed in single quotes ''. I recommend referring to the Configuration Options in the MongoDB docs to learn more about it.

Best regards,
Kushagra