every time when I try to connect to my MongoDB cluster I get this error:
(node:23007) UnhandledPromiseRejectionWarning: Error: read ECONNRESET
at TCP.onread (net.js:622:25)
(node:23007) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23007) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
idk what I do wrong I already added the IP of my glitch project…
Hmmm. Provided the connection string values are all correct that look right on the surface. Do you have any special characters (ones that would need to be url-encoded, for example) in your MONGOUSER or MONGOPASSWORD values?
If I were running into this problem I’d probably try putting the MONGOUSER and MONGOPASSWORD values in the file directly to make sure they’re correct (after putting that file in .gitignore temporarily to make sure your secrets don’t get committed to your git repo) or setting the MONGOPASSWORD to a very basic value temporarily.
Maybe you could add an error handler into your mongoose.connect() call to examine the error returned and see if it provides any useful information? Like
mongoose.connect(uri, function(error) {
// if error is truthy, the initial connection failed.
console.log(error);
})
I see this, but the solution there was to whitelist the IP, which you indicate you already did. Maybe double-triple-check the whitelist? Or open it up wider temporarily (I don’t know MongoDB that well so don’t know if that’s actually a thing you can do)?