node.jsmongodbmongo-shellmongodb-replica-set

Running rs.status() throws BSONError: Invalid UTF-8 string in BSON document in mongosh


I have a simple replica set setup in a single computer with 3 instances. If all 3 instances are running i can check the status with rs.status() in mongosh, however, if I stop one of the instances, I can’t check the status anymore because I get an error. Even if i do it through mongoose in a nodejs server, whenever I try to get the replica set status it just jumps straight to the exception in the title.

I’ve tried with:

db.system.profile.find({}, {}, {enableUtf8Validation: false})

and it didn’t work.

in my Nodejs server i tried connecting through this line:

mongoose.connect("mongodb://127.0.0.1:27017,127.0.0.1:27018,127.0.0.1:27019/term_point?replicaSet=rs0", { family: 4, enableUtf8Validation: false});

it connects to the db but i still get the same exception as soon as i try to get the status.

How can I solve this issue? thank you very much!

Not sure if this is the reason but my computer’s locale is spanish, however, computer name, user name are in english (read somewhere that they were getting the same error in a different place because their computer name had an accent in one of the letters).


Solution

  • Long story short; mongodb hates it if the OS's language is not english.