Hello. Please I have been working on this for days now. Whenever I try to connect to my mongodb database, I keep getting an error like this: Server record does not share hostname with parent URI
This is how my password is formated (Note: It’s in a .env file and I am able to console.log it successfully) MONGODB_URI=mongodb+srv://username:jSnSniWBTlbu4SjX@hostname.fzsalgc.mongodb.net/?retryWrites=true&w=majority
There are no special characters in the password. I have even tried using: MONGODB_URI=mongodb+srv://username:jSnSniWBTlbu4SjX%40@hostname.fzsalgc.mongodb.net/?retryWrites=true&w=majority
still doesn’t work…
There is no DNS entry for it. The fzcalgc.mongodb.net seems correct. You should go back in Atlas and copy the URI from there. You might have use the default name cluster0 so you may try to replace hostname with cluster0.
for (let i = 0; i < addresses.length; i++) {
if (!matchesParentDomain(addresses[i].name, result.hostname, result.domainLength)) {
return callback(
new MongoParseError('Server record does not share hostname with parent URI')
);
}
}
If you want to connect locally you must run mongod locally.
About
Sorry but it is hard to see the difference between fepglzk and fzsalgc in the middle of the text of 2 posts so I did not see that it was different. With the correct cluster address I confirm that there is no DNS issue with.
So it is a node version, or a mongoose version issue or a mongodb driver version issue.
Hey everyone, this can’t be an issue with Node.js, Mongoose, or the MongoDB driver version because I am getting the same error while connecting to the cluster with MongoDB Compass. Sometimes it works with the same URI and sometimes when I change my internet connection, although both internet connections are working.