mern-exercise-tracker-mongodb icon indicating copy to clipboard operation
mern-exercise-tracker-mongodb copied to clipboard

server.js connection

Open justinbalaguer opened this issue 5 years ago • 1 comments

It does work but sometimes when server starts/restarts I get that error and get disconnected to db

[nodemon] starting `node server.js`
Server is running on port: 5000
(node:18433) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 0 to crud-shard-00-02-2su4c.gcp.mongodb.net:27017 closed
    at TLSSocket.<anonymous> (/home/root/Documents/crud/crud-test/backend/node_modules/mongodb/lib/core/connection/connection.js:352:9)
    at Object.onceWrapper (events.js:286:20)
    at TLSSocket.emit (events.js:198:13)
    at _handle.close (net.js:606:12)
    at TCP.done (_tls_wrap.js:388:7)
(node:18433) 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:18433) [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.

I also passed this option { useUnifiedTopology: true } to the MongoClient constructor, but still even without that I still get that error.

justinbalaguer avatar Sep 16 '19 10:09 justinbalaguer

@justinbalaguer - maybe the proxy is blocking your connection to mongodb. You may also consider whitelisting your current IP address to the mongo cluster you are working on

KBPsystem777 avatar Dec 29 '19 18:12 KBPsystem777