My set-up consists of Node.js on Express on the back-end connected to mongoDB through mongoose. When I start the server, I get this error:
Mongo error { Error: querySrv ENODATA `database_hostname`
at errnoException (dns.js:55:10)
at QueryReqWrap.onresolve [as oncomplete] (dns.js:243:19)
code: 'ENODATA',
errno: 'ENODATA',
syscall: 'querySrv',
hostname: `database_hostname` }
This results in me not being able to run my application on localhost due to it being constantly loaded.
At the same time connecting using MongoDB Compass works fine.
The database used to be working fine, but after I changed the location where I have been using it and created manually a new collection in Compass, which did not have a set-up locally, I started getting this error.
Cluster configuration:
SRV Record: off
Read Preference: Primary
SSL: System CA / Atlas Deployment
SSH Tunnel: None
Related
I have created a MongoDB Cloud Database to test my NodeJs Backend.
Ocassionally (probably the 70% of the time), I cant connect and the connect and the console throws the following error log:
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error: querySrv ESERVFAIL _mongodb._tcp.cluster0.u08yi.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (node:dns:213:19) {
errno: undefined,
code: 'ESERVFAIL',
syscall: 'querySrv',
hostname: '_mongodb._tcp.cluster0.u08yi.mongodb.net'
}
The weird thing is that I can connect sometimes. Is it because it is free and then it is prone to fail? It is getting frustrating since sometimes I have to keep updating my nodemon hoping for the ddbb to connect.
I already allowed my IP access.
Im using Mongoose and connecting this way:
mongoose.connect(`mongodb+srv://username:password#cluster0.u08yi.mongodb.net/mydatabase?retryWrites=true&w=majority`,(err)=>{
if(err) throw err;
console.log("MongoDB Connected Successfully");
})
I have been trying to connect to Atlas using the university.mongodb.com connection string:
mongodb+srv://m001-student:m001-mongodb-basics#cluster0-jxeqq.mongodb.net/test
But the compass GUI gives the following error:
queryTxt ETIMEOUT cluster-0-jxeqq.mongodb.net
I created my own cluster and tried again. But unfortunately, the same error showed up. I tried to write a JavaSript code as (the angular placeholders had the actual values in them):
const MongoClient = require('mongodb').MongoClient;
const uri = "mongodb+srv://<user>:<password>#cluster0.amffz.gcp.mongodb.net/<dbname>?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
if (err) return console.log(err);
const collection = client.db("test").collection("collection-1");
client.close();
});
...which gave me this error:
Error: queryTxt ETIMEOUT cluster0.amffz.gcp.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19) {
errno: undefined,
code: 'ETIMEOUT',
syscall: 'queryTxt',
hostname: 'cluster0.amffz.gcp.mongodb.net'
}
In Atlas, I enabled the Network Access in the Security option to :
0.0.0.0/0
I disabled my firewall just to be sure that the connection is not being blocked:
sudo ufw disable
But nothing seems to work.
Any help?
[Edit]
System Config: Ubuntu 20.04 LTS
I figured out that the machine which I was using had some problem with the connectivity.
I figured out the way to solve this. I uninstalled MongoDB. It seemed like it had some configuration issues.
I removed mongodb and mongoose npm packages as well.
Re-installed everything. And viola, it got connected!
mongodb connection error with node and express.
The error:
at QueryReqWrap.onresolve [as oncomplete] (dns.js:206:19) {
errno: undefined,
code: 'ECONNREFUSED',
syscall: 'querySrv',
hostname: '_mongodb._tcp.clustr0-a1rol.mongodb.net'
}
Here are some possible issues with this case:
Check your IP address is whitelisted with your MongoDB client
Check your connection URI once again to check the possible error with that.
Please check this other problem and solution. link
I have faced the same issue, whatever I done is:
restart my node server.
change my database user.
change my network and waiting sometime.
then tried to connect.
this time mongo connection was fine.
N.B- you can check your connection URI too, if its ok. then try with a different network.
i tried to run MongoDB in docker-compose and connect my Go server with MongoDB in docker seem not to work for me, thought i already use mongodb:MyContanerName:27017
when i run my go server and then i tired to request on my client, the error something like this
2019/09/08 14:10:37 Unexpected error: rpc error: code = Internal desc = internal error: server selection error: server selection timeout
current topology: Type: Unknown
Servers:
Addr: mongo:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection(mongo:27017[-125]) connection is closed
i already did docker-compose up -d for my docker, and it was running on my docker ,
the full code is trigger here golang and mongodb
This is related to migration to parse server from api.parse.com.
On windows server, installed mongo db and nodeJS.
Installed Python.
Installed Parse Server.
Getting following error messages.
StyleChat is the name of the app.
http://localhost:1337/stylechat
parse-server-example running on port 1337. info: Parse LiveQuery
Server starts running warn: Unable to ensure uniqueness for usernames:
Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TCP.onread (net.js:564:26) warn: Unable to ensure uniqueness for user email addresses: Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TCP.onread (net.js:564:26) (node:252160) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 4): MongoError: read ECONNRESET (node:252160)
UnhandledPromiseRej
if you run nodejs on window, you should use iisnode to run nodejs on iis.
i found this here
have fun.