diff --git a/lib/url_parser.js b/lib/url_parser.js index 8ced4f11b1..7cc0b2f293 100644 --- a/lib/url_parser.js +++ b/lib/url_parser.js @@ -212,6 +212,7 @@ function parseConnectionString(url, options) { for (let i = 0; i < hosts.length; i++) { let r = parser.parse(f('mongodb://%s', hosts[i].trim())); + if (r.path && r.path.indexOf('.sock') !== -1) continue; if (r.path && r.path.indexOf(':') !== -1) { // Not connecting to a socket so check for an extra slash in the hostname. // Using String#split as perf is better than match.