MongoNetworkError: connect ECONNREFUSED 172.18.44.22:27017 (Windows Server 2019/Windows 10)

46 views Asked by At

I installed:

  • MongoDB v7.0.5 as a service on the Windows Server 2019.
  • Mongosh v2.1.5 on the Windows 10

But when trying to connect the MongoDB server on the Windows Server 2019 from the Windows 10 I receive the following error:

MongoNetworkError: connect ECONNREFUSED 172.18.44.22:27017

I checked:

  • MongoDB service is running
  • The Windows Firewall is configured don't block port 27017 (in/out)

I checked a lot of posts on StackOverflow: most of these related to Linux, the rest are describing solutions that don't help.

What might be problem?


When I launch mongosh locally on the Windows Server 2019 it is running without a problem.

Thanks

1

There are 1 answers

0
Wernfried Domscheit On BEST ANSWER

Double click on the service and have a look at "Path to Executable", should be something like C:\Program Files\MongoDB\mongod.exe --config ...

Have a look at the config file, most likely it contains these lines:

net:
  port: 27017
  bindIp: localhost

Which means, the MongoDB listens to localhost and you can connect only from your local machine. To enable connections from other computers change it to

net:
  port: 27017
  bindIpAll: true

and restart the service.