How can I fix ECONNREFUSED error when the server is running

I want to access a mongodb database using mongosh. I’ve made sure using sudo systemctl status mongod that the server is active, but once I want to access it with mongosh, the following error pops up.

Current Mongosh Log ID:	62319666ca0a2501a0140a38
Connecting to:		mongodb://
MongoNetworkError: connect ECONNREFUSED

I’m willing to provide more information if needed, and thank you all for any assistance in advance!

ECONNREFUSED means no process is listening at the given address and port.

We need 3 things:

  1. the content of the configuration file /etc/mongod.conf
  2. the output of the command
    ps -aef | grep [m]ongod
  3. the output of the command
    ss -tlnp

It seems like the error has been fixed after I reinstall MongoDB and change to a different directory to store the data.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.