MongoDb connection string problem - retryWrites Expected stringified boolean value

Viewed 1946

i have a problem with the connection to an Atlas cluster for mongoDB.

if i try to fetch some data it returns an error

"No write concern mode named 'majority',' found in replica set configuration"

i've looked up the error and everybody says to delete the &w=majority at the end of the connection string.

did that but now i'm facing a new error

UnhandledPromiseRejectionWarning: MongoParseError: For retryWrites Expected stringified boolean value, got: true

I haven't modified the string in any way, it was working yesterday.

my string is

mongodb+srv://username:password@cluster0.yummd.mongodb.net/dbName?retryWrites=true&w=majority

there's no white space or anything at the end of the string, dunno what it is.

any help?

3 Answers

I had the same problem and came across your post. I found out that the problem in my connection was that i had double and than single quotes"'mongodb+srv://username:password@database.aaaa.mongodb.net/collection?retryWrites=true&w=majority'". So the simple solution was just to remove the single quotes. That fixed the issue for me. And then you get : "mongodb+srv://username:password@database.aaaa.mongodb.net/collection?retryWrites=true&w=majority"

I don't know if you have already solved it, but maybe you haven't.

You have some non-printable characters in your URI. Type it out by hand without copy-pasting.

I had the same problem.

There can be two possible reasons:

  1. The line dotenv.config(); should be above const MongoStore = connectMongo;

  2. Check mongodburl for spaces and characters

Related