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 })