Unable to connnect to mongodb

Hi, Recently My mongodb showing this error on my system.It is showing me this error

I tried following things already

  1. Downgrade to a lower version like 3.6.17, 4.0.0 etc.
  2. uninstalled previous mongodb and reinstalled new one.
  3. Mongo shell allows me to connec to DB Easily, even query on collections, GUI tools like ROBO3T also able to make connection without an error.
    4 . Used sudo service mongod restart, Service is uo and running

My node js code is fine as others not facing any issue with the code.Previously it was working fine suddenly it starting throwing this error.

Please help me on this, as this error really stalls my development.

My system details:

Ubuntu 16.04(“Xenial”)

Welcome to the community @Avinash_B!

Based on the error message it looks like your application is trying to connect to a local MongoDB server that is currently not running.

I would definitely work out the issue with your current MongoDB installation rather than changing server versions (which would require following the relevant upgrade or downgrade steps).

What specific versions of MongoDB server, Node.js driver, and Node.js are you using?

To be clear: you are able to connect to localhost:27017 from the same environment as your application using the mongo shell and other admin tools?

What does db.version() return in the mongo shell?

Regards,
Stennie

Hi @Stennie,

Thanks for reply
Yes, i am able to connect with mongo on mongo shell and following versions, i am using on my system.

MongoDB verison
db version v4.4.0

Node Version
v8.14.0

Following are the packages of mongo i am using, from package.json
“mongo-heartbeat”: “~1.0.0”,
“mongodb”: “^3.5.2”,
“mongodb-core”: “^2.1.17”,
“mongoose”: “^5.0.9”,

Anyone here who can help me with this problem?

Here are my mongodb logs

Thanks