Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDb connection string problem - retryWrites Expected stringified boolean value

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:[email protected]/dbName?retryWrites=true&w=majority

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

any help?

like image 349
ChristmasFighters Avatar asked Oct 28 '25 14:10

ChristmasFighters


1 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:[email protected]/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:[email protected]/collection?retryWrites=true&w=majority"

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

like image 55
anzeko Avatar answered Oct 30 '25 14:10

anzeko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!