Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

665
Views
The meaning of ?retryWrites=true&w=majority when you connect Node.js app to Cluster on MongoDB Atlas

When we connect a Node.js application to a cluster on the mongoDB Atlas, we need to add the following URI instead of adding "mongodb://localhost:27017/<dbname>" as you can see at the step 2 in the image.

"mongodb+srv://<username>:<password>@cluster1.tv7cp.mongodb.net/<dbname>?retryWrites=true&w=majority"

Now, what exactly the meaning of ?retryWrites=true&w=majority in it after <dbname>? Why do we need to add it?

I tried and ran the app with mongoose without ?retryWrites=true&w=majority, and it worked fine.

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Retryable writes allow MongoDB drivers to automatically retry certain write operations a single time if they encounter network errors, or if they cannot find a healthy primary in the replica sets or sharded cluster.

Write concern describes the level of acknowledgment requested from MongoDB for write operations to a standalone mongod or to replica sets or to sharded clusters. In sharded clusters, mongos instances will pass the write concern on to the shards. ( if your replica set has 3 members that mean that your majority=2 , meaning that your write operation will receive acknowledgment after it receive success confirmation from at least 2 members)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!