MongoNetworkError: connect ECONNREFUSED <mongos instance IP Address>

Hi,
I am working on configuring one config server, shard and a mongos router. I have been able to setup config server and shard and they are running on their respective IP addresses. I am able to mongosh into both of them and rs.status() seems to give correct result. I have mongos running on different instance however unable to mongosh into it. Below is mongos.conf I am using

systemLog:
  destination: file
  path: /var/log/mongodb/mongos.log
  logAppend: true
processManagement:
  fork: true
net:
  bindIp: router1
sharding:
  configDB: test-configsrv-replica/cfg1:27019

Status of mongos server

root@configsrv3-ubuntu22-04lts-scpu-1gb-cdg1-1:~# sudo systemctl status mongos
● mongos.service - MongoDB Shard Router
     Loaded: loaded (/etc/systemd/system/mongos.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-06-29 12:06:31 UTC; 1s ago
   Main PID: 190600 (mongos)
      Tasks: 16 (limit: 1101)
     Memory: 14.4M
        CPU: 17ms
     CGroup: /system.slice/mongos.service
             ├─190600 /usr/bin/mongos --config /etc/mongos.conf
             ├─190601 /usr/bin/mongos --config /etc/mongos.conf
             └─190602 /usr/bin/mongos --config /etc/mongos.conf

I have router1 (mapped to IP of mongos instance itself) and cfg1 mapped in /etc/hosts with correct IP addresses
Below is the error

root@configsrv3-ubuntu22-04lts-scpu-1gb-cdg1-1:~# mongosh --host xxx.xxx.xxx.xxx
Current Mongosh Log ID: 649d758964c015107f2b959a
Connecting to:          mongodb://xxx.xxx.xxx.xxx:27017/?directConnection=true&appName=mongosh+1.10.1
MongoNetworkError: connect ECONNREFUSED xxx.xxx.xxx.xxx:27017

Any help would be appreciated, Thanks!

Hi @Jay_Bhanushali1,
I think the parameter that isn’ t set correctly Is bindip.

From the documentation:

Regards

Hi @Fabio_Ramohitaj ,
It was setted up correctly however somehow the mongos service which I was runnning using systemctl mongos start was different that running mongos using mongos --config <path-to-config> . The second option worked for me which was by using the mongos in command line. Thanks!

1 Like