4

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?

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

2 Comments

Thanks for the answer. But I haven't really modified it in any way. That string has been living on the .env file for the past few weeks
@ChristmasFighters How did you ended up fixing it?
0

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

1 Comment

this was the case for me I copied the string from Atlas and pasted it in VS code. My formatter(Prettier) edited it while saving and added a linebreak and a blank space in it. So i just saved my username and pswd in my .env file and used it in the uri.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.