Mongoose v5.2.1
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Mongo connection error when trying to connect to MongoDB Atlas database..
{ MongoError: seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name
at connectCallback (/node_modules/mongodb/lib/operations/mongo_client_ops.js:236:23)
at process.nextTick (/node_modules/mongodb/lib/operations/mongo_client_ops.js:436:7)
at process._tickCallback (internal/process/next_tick.js:61:11)
name: 'MongoError',
message:
'seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name',
[Symbol(mongoErrorContextSymbol)]: {} }
If the current behavior is a bug, please provide the steps to reproduce.
mongoose.connect(process.env.MONGO_URL, {
reconnectTries: 100,
reconnectInterval: 500,
autoReconnect: true,
useNewUrlParser: true,
dbName: 'test'
})
.catch(err => console.log('Mongo connection error', err))
Where MONGO_URL looks like mongodb+srv://<username>:<password>@<url>?retryWrites=true
What is the expected behavior?
Should connect successfully
Please mention your node.js, mongoose and MongoDB version.
node v10.5.0
mongoose v5.2.1
mongodb v3.6.5
@khaledosman are you passing the option { useNewUrlParser: true }
into your mongoose connection? There is a bug that will be fixed with the next release of the native driver that causes the new url parser to not work with the srv uri string. see #6656 for more info.
For the moment In order to use the srv uri you'll need to use the old uri parser and live with the deprecation warning node --no-deprecation
, or alternatively you can connect to mongodb with just the hosts and ports in the non-srv uri string, and everything else in the options object. i posted a comment here using my atlas connection details as an example.
commenting the "useNewUrlParser" option and removing retryWrites from the url fixed the problem. Thanks for the quick reply!
Most helpful comment
@khaledosman are you passing the option
{ useNewUrlParser: true }
into your mongoose connection? There is a bug that will be fixed with the next release of the native driver that causes the new url parser to not work with the srv uri string. see #6656 for more info.For the moment In order to use the srv uri you'll need to use the old uri parser and live with the deprecation warning
node --no-deprecation
, or alternatively you can connect to mongodb with just the hosts and ports in the non-srv uri string, and everything else in the options object. i posted a comment here using my atlas connection details as an example.