Local instance of Mongo DB. Creating a connection string

Hi all… I am extremely new to Mongo DB… I’ve used SQL Server in the past quit a bit.
I just installed a local instance of Mongo, not Atlas, just a local db instance. This instance happens to be running in a Microsoft Azure VM instance.

I installed the MongoDB plugin into Visual Studio code and I am trying to connect.

When I use the following connection string, inside VS Code running on the exact same VM, I can connect just fine.


However, if I try to connect using VS Code running on the same machine but this time using the IP Address of the machine rather than localhost
```mongodb://xx.xx.xx.xx:27017/

Where xx.xx.xx.xx is the VMs IP Addr, I end up getting this error

`Unable to connect: connect ECONNREFUSED xx.xx.xx.xx:27017`

Ultimatly what I am trying to figure out how to do here is figure out how to connect to the mongo DB running on the VM from a different computer...   

Is this possible, or can this not be done from something like the community edition?

Thanks for any help and feedback!

means no process is listening at the given xx.xx.xx.xx IP.

Connect to the xx.xx.xx.xx machine and try to connect with mongosh using the same connection string. Does it work? No try with localhost rather than xx.xx.xx.xx. Does that work better?

Share the mongod configuration file you used to start the instance. I suspect you are not binding to xx.xx.xx.xx.

I am assuming that Mongosh is a different download correct? Might be an issue, the company I work for has very restrictive policies in place. Its odd… In our local company software repo, we have Mongo and Compass, but not MongoSH.

For clarification, it was on the same machine that Mongo is running that I tried to use the IPAddress rather than localhost…

When you mention config file, I am assuming this is what you are referring to. I have not edited this file at all.

BTW, I am running Mongo 7.0

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: C:\Program Files\MongoDB\Server\7.0\data

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path:  C:\Program Files\MongoDB\Server\7.0\log\mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

You are not binding with the IP address of the VM. You only bind to localhost.

@Rick_Blacker, if your issue is resolve it would be nice to know. Thanks for sharing.