We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node >= 17 use IPv6 by default, not compatible with MongoDB by default. This patch can be used to use IPv4:
diff --git a/node_modules/mongodb-topology-manager/lib/utils.js b/node_modules/mongodb-topology-manager/lib/utils.js index c16f717..1acbbfd 100644 --- a/node_modules/mongodb-topology-manager/lib/utils.js +++ b/node_modules/mongodb-topology-manager/lib/utils.js @@ -27,6 +27,10 @@ function cleanupSocket(socket) { * @param {function} callback */ function checkAvailable(host, port, callback) { + // Use IPv4 since MongoDB does not currently support automatically IPv6 + require('node:dns').lookup(host, { family: 4 }, (err, ipv4) => { + if (err) console.error(err); + //console.log(`IPv4: ${ipv4}`); const socket = new net.Socket(); socket.on('connect', () => { @@ -43,7 +47,8 @@ function checkAvailable(host, port, callback) { callback(null, false); }); - socket.connect({ port: port, host: host }); + socket.connect({ port: port, host: ipv4 }); + }); } /**
The text was updated successfully, but these errors were encountered:
Or just add a command line option to bind servers to IPv6 addresses in index.js:
index.js
const options = { port: port, dbpath: isWin ? `${dbPath}\\${port}` : `${dbPath}/${port}`, - bind_ip: hostname + bind_ip: hostname, + ipv6: null, };
Sorry, something went wrong.
No branches or pull requests
Node >= 17 use IPv6 by default, not compatible with MongoDB by default.
This patch can be used to use IPv4:
The text was updated successfully, but these errors were encountered: